Skip to content

Commit 6d3ec0f

Browse files
add switch default
1 parent 6072f00 commit 6d3ec0f

File tree

6 files changed

+15
-2
lines changed

6 files changed

+15
-2
lines changed

src/main/java/com/thealgorithms/datastructures/hashmap/hashing/Main.java

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ public static void main(String[] args) {
4444
In.close();
4545
return;
4646
}
47+
default: {
48+
throw new IllegalArgumentException("Unexpected value: " + choice);
49+
}
4750
}
4851
}
4952
}

src/main/java/com/thealgorithms/datastructures/hashmap/hashing/MainCuckooHashing.java

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ public static void main(String[] args) {
6262
h.reHashTableIncreasesTableSize();
6363
break;
6464
}
65+
default: {
66+
throw new IllegalArgumentException("Unexpected value: " + choice);
67+
}
6568
}
6669
}
6770
}

src/main/java/com/thealgorithms/misc/Sort012D.java

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ public static void sort012(int[] a) {
5151
h--;
5252
break;
5353
}
54+
default: {
55+
throw new IllegalArgumentException("Unexpected value: " + a[mid]);
56+
}
5457
}
5558
}
5659
System.out.println("the Sorted array is ");

src/main/java/com/thealgorithms/sorts/DNFSort.java

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ static void sort012(int[] a, int arr_size) {
3131
high--;
3232
break;
3333
}
34+
default:
35+
throw new IllegalArgumentException("Unexpected value: " + a[mid]);
3436
}
3537
}
3638
}

src/main/java/com/thealgorithms/stacks/PostfixToInfix.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public static boolean isOperator(char token) {
2828
case '*':
2929
case '^':
3030
return true;
31+
default:
32+
return false;
3133
}
32-
33-
return false;
3434
}
3535

3636
public static boolean isValidPostfixExpression(String postfix) {

src/main/java/com/thealgorithms/strings/ValidParentheses.java

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public static boolean isValid(String s) {
2626
case ']':
2727
if (head == 0 || stack[--head] != '[') return false;
2828
break;
29+
default:
30+
throw new IllegalArgumentException("Unexpected character: " + c);
2931
}
3032
}
3133
return head == 0;

0 commit comments

Comments
 (0)