Problem with my Vectors

Joel Rowley <hjoelr-/[email protected]> Wed, 26 May 2004 19:14:14 -0700 (PDT)
Newsgroups gmane.comp.hardware.microcontrollers.tini
Message-ID <[email protected]>
Hey List,
 
I created a simple program that adds an instance of my
class to a vector.  Here is my program:

-------------------------------------------------
import java.util.*;

import com.dalsemi.system.Debug;

public class VectorTest {
	
	public static void main(String[] args) {
		Debug.setDefaultStreams();
		Vector vecTest = new Vector(8, 2);
		vecTest.addElement(new TestClass("theName"));
	
System.out.println(((TestClass)vecTest.elementAt(0)).getTheName());
		vecTest.addElement(new TestClass("theName1"));
	
System.out.println(((TestClass)vecTest.elementAt(0)).getTheName());
	
System.out.println(((TestClass)vecTest.elementAt(1)).getTheName());
	}
}
-----------------------------------------------

Here is what my TestClass looks like:

-----------------------------------------------
public class TestClass {
	
	private static String theName;
	
	TestClass(String name) {
		theName = name;
	}
	
	public String getTheName() {
		return theName;
	}
	
}
-----------------------------------------------

>From what it looks like, the program should output
this:

theName
theName
theName1

But, what it outputs this:

theName
theName1
theName1

What is my problem?

Thanks!
Joel Rowley
_______________________________________________
TINI mailing list
TINI-6tN4nzCoH/[email protected]
To UNSUBSCRIBE, edit your profile, or see list archives:
http://lists.dalsemi.com/mailman/listinfo/tini