+ 6
Please explain the output of this code.
8 Answers
+ 8
@Geo, it's not my code. I just found it in a java challange and i was not able to understand its output. That's why I ask.
+ 6
thanks
+ 5
Normaly you have to use break in you case to exit the switch :
switch (a){
case 1 :
++x;
break;
case 2:
++x;
break;
case 3:
++x;
break;
default :
++x;
}
+ 4
@Geo, it's not my code. I just found it in a java challange and i was not able to understand its output. That's why I ask.
+ 4
@Arushi Ok, no problem âș
+ 3
I don't understand why it's giving o/p as 3!
Actual o/p should be 1
+ 2
@èă
ćæ oh yeah mate!
+ 1
the x value will be increase by incremental and the value in case of 2