Computer Science, asked by Anonymous, 1 year ago

What is a fall through condition in Java?

Answers

Answered by Rakki04
5
In Switch block, if 'break;' isn't applied at the end of a case, then, the statements included within the previous case as well as the next case would be executed.
example:
switch(n)
{
case 1:
System.out.println("hello");
break;
case 2:
System.out.println("bye");
}

In the above example, hello is printed only if n=1. But, if break; isn't applied, both hello and bye are executed irrespective of weather n=1 or not.
Similar questions