Thursday, March 5, 2015

Java break statement in a java pgm



Java break statement

public class JavaBreakExample
 {
public static void main(String[] args)
{
int intArray[] = new int[]{1,2,3,4,5};   
System.out.println("Elements less than 3 are : ");
for(int i=0; i < intArray.length ; i ++)
{  
if(intArray[i] == 3)
break;
else
System.out.println(intArray[i]);
     }
   }
}

No comments:

Post a Comment