FileDocCategorySizeDatePackage
FinalVariables.javaAPI DocExample2432Sun Dec 14 22:47:38 GMT 2003oreilly.hcj.finalstory

FinalVariables

public class FinalVariables extends Object
Demonstration of final variables.
author
Robert Simmons jr. (kraythe)
version
$Revision: 1.3 $

Fields Summary
Constructors Summary
Methods Summary
public voidbuildGUIDialog(java.lang.String name)
build the panel that comprises the dialog.

param
name The name of the instance.

		final String instanceName;
		if (name == null) {
			// no problem here.
			instanceName = getClass()
				               .getName() + hashCode();
		} else {
			// no problem here as well.
			instanceName = getClass()
				               .getName() + name;
		}

		JDialog dialog = new JDialog();

		// .. Do a bunch of layout and component building. 
		dialog.setTitle(instanceName);

		// .. Do dialog assembly
		// instanceName = "hello";  // <= compiler error
	
public static final voidmain(java.lang.String[] args)
Test code.

param
args Command line arguments.

		System.out.println("Note how the key variable is changed.");
		someMethod("JAVA_HOME");
		someMethod("ANT_HOME");
	
public static java.lang.StringsomeBuggedMethod(java.lang.String environmentKey)
Get an environment property.

param
environmentKey The key to an environment property.
return
The value of the property.

		final String key = "env." + environmentKey;
		System.out.println("Key is: " + key);
		// key = new String("someValue"); // <= compiler error.  
		return (System.getProperty(key));
	
public static java.lang.StringsomeMethod(java.lang.String environmentKey)
Get an environment property.

param
environmentKey The key to an environment property.
return
The value of the property.

		final String key = "env." + environmentKey;
		System.out.println("Key is: " + key);
		return (System.getProperty(key));