FileDocCategorySizeDatePackage
PointersAndReferences.javaAPI DocExample1915Sun Dec 14 22:47:38 GMT 2003oreilly.hcj.review

PointersAndReferences

public class PointersAndReferences extends Object
Demonstration of the Pointers and References Concept.
author
Robert Simmons jr. (kraythe)
version
$Revision: 1.3 $

Fields Summary
Constructors Summary
Methods Summary
public static final voidmain(java.lang.String[] args)
Main method.

param
args Command Line arguments.

		Vector source = new Vector();
		source.add("O'Reilly");
		source.add("XML");
		source.add("Java");
		System.out.println("Original Vector");
		System.out.println(source.toString());
		// -- Try the first method. 
		someMethod(source);
		System.out.println("After first method.");
		System.out.println(source.toString());
		// -- Try the second method. 
		someOtherMethod(source);
		System.out.println("After second method.");
		System.out.println(source.toString());
	
public static voidsomeMethod(java.util.Vector source)
Try using a vector without changing it.

param
source The source Vector.

		Vector target = source;
		target.add("Swing");
	
public static voidsomeOtherMethod(java.util.Vector source)
Try using a vector without changing it with final parameter.

param
source The source Vector.

		Vector target = source;
		target.add("JFC");  // ouch, still changes v.
		// source = new Vector(); // compiler error.