Can someone please explain break statements to me, as far as i understand a break statement leaves the loop before it has ended.
But i run this code and expect to get
"Zero"
"One"
But I get
"Zero"
"One"
"One"
"Unknown number"
for (int i = 0; i < 3; i++)
{
switch(i)
{
case 0:
{
System.out.println("zero ");
}
case 1:
{
System.out.println("one");
break;
}
default:
{
System.out.println("unknown number");
}
}
}
Help please, can someone explain this to me in steps as i have confused myself badly