switch
Posted: Wed Apr 26, 2023 9:36 am
I am struggling to understand why the output is C and F. Could someone explain this for me please
What letters will be printed by this program?
What letters will be printed by this program?
Code: Select all
public class ForSwitch
{
public static void main(String args[])
{
char i;
LOOP: for (i=0;i<5;i++)
{
switch(i++)
{
case '0': System.out.println("A");
case 1: System.out.println("B"); break LOOP;
case 2: System.out.println("C"); break;
case 3: System.out.println("D"); break;
case 4: System.out.println("E");
case 'E' : System.out.println("F");
}
}
}
}