Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

La Boucle For: Exemple des plusieur modèles


{filelink=4391}

 
import java.util.Iterator;
import java.util.Properties;
import java.util.Set;
 
public class BoucleFor {
 
  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));
    }
  }
 
  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));
    }
  }
 
  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));
    }
  }
 
  public static void forSimple(final String[] args) {
    for (int idx = 0; idx < args.length; idx++) {
      // .. Faire quelque chose
    }
  }
 
  public static void forWeird() {
    boolean exit = false;
    int idx = 0;
 
    for (System.setProperty("user.sanity", "minimal"); exit == false; System.out.println(System
        .currentTimeMillis())) {
      // Faire quelque chose.
      idx++;
      if (idx == 10) {
        exit = true;
      }
    }
  }
 
  public static void main(String[] args) {
    forWeird();
  }
 
  public static void propsDump(final Set customKeys) {
    Properties props = System.getProperties();
    Iterator iter = props.keySet().iterator();
 
    String key = null;
    System.out.println("Toutes les propri�t�s:");
    while (iter.hasNext()) {
      key = (String) iter.next();
      System.out.println(key + "=" + System.getProperty(key));
    }
 
    System.out.println("Propri�t�s personnalis�e:");
    iter = customKeys.iterator();
    while (iter.hasNext()) {
      System.out.println(key + "=" + System.getProperty(key));
    }
  }
}

A Voir sur le même Sujet:

  • la methode System .currentTimeMillis() en java
  • for
  • java messageformat décalage de 1 an et 12h
  • programme en java une application de chating entre plusieur machines
  • exemple de plusieur