Source Code : For loop: all conditions

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

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 = (String) iter.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 = (String) iter.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 = (String) iter.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 = (String) iter.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 ########## */

           
         
  

Thank with us