+ 2
Can you teach me what is break statement and switch block
i didn't understand from this bcoz it is confusing me
3 Respuestas
+ 1
break statement
a break statement is used to go out from the box you're inside the box may be for loop or while loop or switch statement.
switch statement
its like a gun with options ex
switch (x)
{
case 1;
case 2;
default;
}
each case is an aim to the gun one of them is present you shot it .
+ 1
break statements are used to go outside of the nearest block of loops or switch.
0
Switch works as else if ladder
I matches the value of variable with the given cases when a match is found the case is executed and then there's a need to break the process of matching further or executing the further cases that's why break is used to jump outa switch block