Click here to watch in Youtube :
https://www.youtube.com/watch?v=XHbrM7iNO8E&list=UUhwKlOVR041tngjerWxVccw
BreakWithLabelDemo.java
Output
https://www.youtube.com/watch?v=XHbrM7iNO8E&list=UUhwKlOVR041tngjerWxVccw
BreakWithLabelDemo.java
class BreakWithLabelDemo { public static void main(String[] args) { /* * An unlabeled break statement terminates the innermost switch, for, * while, or do-while statement, but a labeled break terminates an outer * statement. */ int[][] arrayOfInts = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }; int searchfor = 2; int i; int j = 0; boolean foundIt = false; search: for (i = 0; i < arrayOfInts.length; i++) { System.out.println("i:" + i); for (j = 0; j < arrayOfInts[i].length; j++) { System.out.println("arrayOfInts[" + i + "]" + "[" + j + "] : " + arrayOfInts[i][j]); if (arrayOfInts[i][j] == searchfor) { foundIt = true; break search; } } System.out.println("for loop j is completed."); } System.out.println("for loop i is completed."); if (foundIt) { System.out.println("Found " + searchfor + " at " + i + ", " + j); } else { System.out.println(searchfor + " not in the array"); } } }
i:0 arrayOfInts[0][0] : 1 arrayOfInts[0][1] : 2 for loop i is completed. Found 2 at 0, 1
https://sites.google.com/site/javaee4321/java/ControlFlowDemoBreakLabelArrayApp.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/ControlFlowDemoBreakLabelArrayApp
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/2f20a20e875ab6e7de15adc0041c373263d61c3b/BasicJava/ControlFlowDemoBreakLabelArrayApp/?at=master
See also:
salesforce training
ReplyDeletesalesforce online training
Say, you got a nice article post.Really thank you! Really Great.
ReplyDeletedata science training india
data science course hyderabad online