break statement in Java Android example

break statement in Java Android basic example

MainClass.java

public class MainClass {
	public static void main(String[] arg) {
		String[] arrayOfString = {"nothing", "Hello", "people"
				, "bye-bye", "hello", "world!", "end" };
 
		for (int i = 0; i < arrayOfString.length; i++) {
				System.out.println(arrayOfString[i]);
				if(i > 2) 
					break; // end of loop
		}
	}
}
/*
nothing
Hello
people
bye-bye
*/
This entry was posted in Android Examples Code and tagged , , , . Bookmark the permalink.


Comments are closed.

7,134 views