public class Demo {
public static void main(String args[]) {
char c = 'A' ;
int num = 10 ;
switch(c) {
case 'B' :
num++ ;
case 'A' :
num++ ;
case 'Y' :
num++ ;
break ;
default :
num-- ;
}
System.out.println(num);
}
}
I think the program will passed case 'A'
so the num will be 11.
I ran it in Idea and saw that the program passed case 'A'
and case 'Y'
(???). Finally, the num is 12.
I try this:
System.out.println('A' == 'Y');
and it returnfalse