Showing posts with label java break keyword. Show all posts
Showing posts with label java break keyword. Show all posts

Java- break keyword / Chapter -7 / Flow Control



Java break keyword


The break keyword is used to break the control flow from switch & loops.


We can use break keyword in following places.


  • Inside switch ( ) to stop fall through.


example:
int x=0

switch(x)

{

  case 0 :

              System.out.println(0);

case 1 :
System.out.println(1);
break;
case 2 :
System.out.println(2);

default : System.out.println(default);
}
Output is :   0
1

  • Inside loop to break loop execution based on some condition.


example:-

Flipkart End Of Season Sale






© Copyright 2017 Javabychetan.blogspot.com