code_junkie

Should I avoid using Java Label Statements?

Nov 10th, 2011
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. class MyFirstJavaProg {
  2. public static void main(String args[]) {
  3. http://www.javacoffeebreak.com/java101/java101.html
  4. System.out.println("Hello World!");
  5. }
  6. }
  7.  
  8. sentence: for(final Sentence sentence: paragraph) {
  9. for(final String word: sentence) {
  10. // do something
  11. continue sentence;
  12. }
  13. }
  14.  
  15. `private static void testByFactoring() {
  16.  
  17. {
  18.  
  19. primes: for (int ctr = 0; ctr < m_toFactor.length; ctr++) {
  20.  
  21. int toTest = m_toFactor[ctr];
  22.  
  23. for (int ctr2 = 0; ctr2 < m_divisors.length; ctr2++) {
  24.  
  25. // max (int) Math.sqrt(m_numberToTest) + 1 iterations
  26.  
  27. if (toTest != m_divisors[ctr2]
  28. && toTest % m_divisors[ctr2] == 0) {
  29. continue primes;
  30. }
  31.  
  32. } // end of the divisor loop
  33.  
  34. } // end of primes loop
  35.  
  36. } // method`
  37.  
  38. nextItem: for(CartItem item : user.getCart()) {
  39.  
  40. nextCondition : for(PurchaseCondition cond : item.getConditions()) {
  41. if(!cond.check())
  42. continue nextItem;
  43. else
  44. continue nextCondition;
  45.  
  46. }
  47. purchasedItems.add(item);
  48. }
Add Comment
Please, Sign In to add comment