You are here: Home / Topics / Break statement example in Java

Break statement example in Java

Filed under: Java on 2023-08-18 06:43:35

// Break startment in for loop example

public class BreakStatement{

   public static void main(String[] args) {

       for (int i = 0; i < 10; i++) {
           System.out.println(i);
           if(i==5){
               break;
           }
       }
       System.out.println("loop over");
   }
}


Output:

0
1
2
3
4
loop over

About Author:
Y
Yatendra Sir     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.