Skip to content

Commit ab942e5

Browse files
committed
Update OnesComplement implementation
1 parent ef986c4 commit ab942e5

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/main/java/com/thealgorithms/bitmanipulation/OnesComplement.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ public static String onesComplement(String binary) {
2727
StringBuilder complement = new StringBuilder(binary.length());
2828
for (char bit : binary.toCharArray()) {
2929
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-
}
30+
case '0': complement.append('1');
31+
case '1': complement.append('0');
32+
default: throw new IllegalArgumentException("...");
33+
}
3434
}
3535
return complement.toString();
3636
}

0 commit comments

Comments
 (0)