Sign up to request clarification or add additional context in comments.
Comments
0
What is the data type of a & b ?
If it is boolean then it won't work, switch works with int.
If they are int then you must use single & operation and not a &&
public static void main(String[] args) {
int a,b;
a=5;
b=2;
switch(a & b){
case 1:
//
case 2:
//
}
aandband why would you expect&&to produce either 1 or 2 when this operator returns aboolean?