For loop: all conditions : For « Language Basics « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Collections Data Structure
8. Database SQL JDBC
9. Design Pattern
10. Development Class
11. Email
12. Event
13. File Input Output
14. Game
15. Hibernate
16. J2EE
17. J2ME
18. JDK 6
19. JSP
20. JSTL
21. Language Basics
22. Network Protocol
23. PDF RTF
24. Regular Expressions
25. Security
26. Servlets
27. Spring
28. Swing Components
29. Swing JFC
30. SWT JFace Eclipse
31. Threads
32. Tiny Application
33. Velocity
34. Web Services SOA
35. XML
Microsoft Office Word 2007 Tutorial
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Java » Language Basics » ForScreenshots 
For loop: all conditions

/*
 *     file: ForLoops.java
 *  package: java2s.hcj.review
 *
 * This software is granted under the terms of the Common Public License,
 * CPL, which may be found at the following URL:
 * http://www-124.ibm.com/developerworks/oss/CPLv1.0.htm
 *
 * Copyright(c) 2003-2005 by the authors indicated in the @author tags.
 * All Rights are Reserved by the various authors.
 *
 ########## DO NOT EDIT ABOVE THIS LINE ########## */

import java.util.Iterator;
import java.util.Properties;
import java.util.Set;

/**
 * Syntax check file for for loops.
 
 @author <a href="mailto:kraythe@arcor.de">Robert (Kraythe) Simmons jr.</a>
 */
public class ForLoops {
  /**
   * A wordy for loop.
   */
  public static void forLong() {
    Properties props = System.getProperties();
    Iterator iter = props.keySet().iterator();

    String key = null;
    while (iter.hasNext()) {
      key = key = (Stringiter.next();
      System.out.println(key + "=" + System.getProperty(key));
    }
  }

  /**
   * A completely safe and short for loop.
   */
  public static void forSafe() {
    Properties props = System.getProperties();
    Iterator iter = props.keySet().iterator();
    for (String key = null; iter.hasNext(); key = (Stringiter.next()) {
      System.out.println(key + "=" + System.getProperty(key));
    }
  }

  /**
   * A short for loop.
   */
  public static void forShort() {
    Properties props = System.getProperties();
    for (Iterator iter = props.keySet().iterator(); iter.hasNext();) {
      String key = (Stringiter.next();
      System.out.println(key + "=" + System.getProperty(key));
    }
  }

  /**
   * A simple for loop.
   
   @param args
   *          Arguments to the loop.
   */
  public static void forSimple(final String[] args) {
    for (int idx = 0; idx < args.length; idx++) {
      // .. do something.
    }
  }

  /**
   * A weird for loop.
   */
  public static void forWeird() {
    boolean exit = false;
    int idx = 0;

    for (System.setProperty("user.sanity""minimal"); exit == false; System.out.println(System
        .currentTimeMillis())) {
      // do some code.
      idx++;
      if (idx == 10) {
        exit = true;
      }
    }
  }

  /**
   * Demo method.
   
   @param args
   *          Command line args.
   */
  public static void main(String[] args) {
    forWeird();
  }

  /**
   * A for loop bug.
   
   @param customKeys
   *          __UNDOCUMENTED__
   */
  public static void propsDump(final Set customKeys) {
    Properties props = System.getProperties();
    Iterator iter = props.keySet().iterator();

    String key = null;
    System.out.println("All Properties:");
    while (iter.hasNext()) {
      key = (Stringiter.next();
      System.out.println(key + "=" + System.getProperty(key));
    }

    System.out.println("Custom Properties:");
    iter = customKeys.iterator();
    while (iter.hasNext()) {
      System.out.println(key + "=" + System.getProperty(key));
    }
  }
}

/* ########## End of File ########## */

           
       
Related examples in the same category
1. for Demofor Demo
2. Check out for loopCheck out for loop
3. Java labeled for loop.Java labeled for loop.
4. Demonstrates for loop by listing all the lowercase ASCII letters.Demonstrates for loop by listing all the lowercase ASCII letters.
5. Comma OperatorComma Operator
6. Java program to demonstrate looping 1Java program to demonstrate looping 1
7. Java program to demonstrate loopingJava program to demonstrate looping
ww__w__.___j___a___v__a__2s_._c_o_m | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.