We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ef986c4 commit ab942e5Copy full SHA for ab942e5
1 file changed
src/main/java/com/thealgorithms/bitmanipulation/OnesComplement.java
@@ -27,10 +27,10 @@ public static String onesComplement(String binary) {
27
StringBuilder complement = new StringBuilder(binary.length());
28
for (char bit : binary.toCharArray()) {
29
switch (bit) {
30
- case '0' -> complement.append('1');
31
- case '1' -> complement.append('0');
32
- default -> throw new IllegalArgumentException("Input must contain only '0' and '1'. Found: " + bit);
33
- }
+ case '0': complement.append('1');
+ case '1': complement.append('0');
+ default: throw new IllegalArgumentException("...");
+ }
34
}
35
return complement.toString();
36
0 commit comments