Biblioteca Java - Blame information for rev 39

Subversion Repositories:
Rev:
Rev Author Line No. Line
39 mihai 1 package introducere.java.breackcontinue;
4 mihai 2  
3 /**
4  * Exemplify the use of the continue statement. This can be used to skip the current
5  * iteration of a for, while , or do-while loop.
6  */
7 class ContinueDemo {
8     public static void main(String[] args) {
9  
10         String searchMe = "peter piper picked a peck of pickled peppers";
11         int max = searchMe.length();
12         int numPs = 0;
13  
14         for (int i = 0; i < max; i++) {
15             //interested only in p's
16             if (searchMe.charAt(i) != 'p')
17                 continue;
18  
19             //process p's
20             numPs++;
21         }
22         System.out.println("Found " + numPs + " p's in the string.");
23     }
24 }