We Offer 100% Job Guarantee Courses (Any Degree / Diploma Candidates / Year GAP / Non-IT / Any Passed Outs). Placement Records
Hire Talent (HR):+91-9707 240 250

General

Break Statement in Java

Break Statement in Java

Break Statement in Java

In order to exit from a flow of execution break statement is used. It can be used with for, if, while, do-while, switch statements, etc…

Examples

Class Country{
public static void main(String args[]) {
public static final String GER=”Germany”;
List<String> listValues= new ArrayList<String>();
listValues.add(“India”);
listValues.add(“Germany”);
listValues.add(“Brazil”);
listValues.add(“Norway”); 
boolean flag = false;
for(int i=0;i<listValues.size();i++)
{
if(listValues.get(i).equalsIgnoreCase(GER))
   { flag= true;
     break;
    }
}
if(flag=true)
{
System.out.println(“Germany is SuperPower”);
}
}

Points to remember:

  • The execution of the project will stop once it reach to the break point.
  • It will be out of the program.
  • When the project need to stop the program after few condition and want to stop the project exaction then we need the switch condition

Click Here-> Get Java Training with Real-time Projects

Besant Technologies WhatsApp