+ 6
Please explain the output of this code.
8 odpowiedzi
+ 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