FileDocCategorySizeDatePackage
ForLoops.javaAPI DocExample3074Sun Dec 14 22:47:40 GMT 2003oreilly.hcj.review

ForLoops

public class ForLoops extends Object
Syntax check file for for loops.
author
Robert (Kraythe) Simmons jr.

Fields Summary
Constructors Summary
Methods Summary
public static voidforLong()
A wordy for loop.

		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 voidforSafe()
A completely safe and short for loop.

		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 voidforShort()
A short for loop.

		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 voidforSimple(java.lang.String[] args)
A simple for loop.

param
args Arguments to the loop.

		for (int idx = 0; idx < args.length; idx++) {
			// .. do something. 
		}
	
public static voidforWeird()
A weird for loop.

		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;
			}
		}
	
public static voidmain(java.lang.String[] args)
Demo method.

param
args Command line args.

		forWeird();
	
public static voidpropsDump(java.util.Set customKeys)
A for loop bug.

param
customKeys __UNDOCUMENTED__

		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));
		}