Results 1 to 1 of 1
Thread: How to use Continue with a label
-
How to use Continue with a label
Java Code:public class ContinueWithLabelDemo { public static void main(String[] args) { String searchMe = "Look for a substring in me"; String substring = "sub"; boolean foundIt = false; int max = searchMe.length() - substring.length(); test: for (int i = 0; i <= max; i++) { int n = substring.length(); int j = i; int k = 0; while (n-- != 0) { if (searchMe.charAt(j++) != substring.charAt(k++)) { continue test; } } foundIt = true; break test; } System.out.println(foundIt ? "Found it" : "Didn't find it"); } }"The sole cause of man’s unhappiness is that he does not know how to stay quietly in his room." - Blaise Pascal
Similar Threads
-
How to use Continue
By Java Tip in forum java.langReplies: 0Last Post: 04-17-2008, 07:46 PM -
How to use Break with a label
By Java Tip in forum java.langReplies: 0Last Post: 04-17-2008, 07:45 PM -
Getting disk label
By Java Tip in forum Java TipReplies: 0Last Post: 02-05-2008, 09:07 AM -
Example of SWT Label
By Java Tip in forum Java TipReplies: 0Last Post: 01-09-2008, 12:02 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks