FileDocCategorySizeDatePackage
MethodAndField.javaAPI DocExample405Tue Jun 18 16:29:44 BST 2002None

MethodAndField.java

/** Show a class that has a method and a field with the same name (and type).
 */
public class MethodAndField {
	/** A method named "a" */
	int a() {
		return 42;
	}

	/** A field named a (whose value is computed by method a for good measure)
	 */
	int a = a();

	/** A main method to show that it all works. */
	public static void main(String[] args) {
		System.out.println(new MethodAndField().a);
	}
}