Accessing a method inside of an object that is stored in a vector...
From: da Vinci (blank_at_blank.com)
Date: 12/05/04
- Next message: Raymond DeCampo: "Re: Accessing a method inside of an object that is stored in a vector..."
- Previous message: IchBin: "Re: why does this program not end?"
- Next in thread: Raymond DeCampo: "Re: Accessing a method inside of an object that is stored in a vector..."
- Reply: Raymond DeCampo: "Re: Accessing a method inside of an object that is stored in a vector..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 05 Dec 2004 01:22:53 GMT
I have been trying to post to .help all day but nothing is going
through. Will try it here and hope it does....
I am trying to access a getData() method that simply returns a stored
integer value from an object that is stored in a vector. I have tried
to do this but cannot get the notation correct. I tried google groups
and the only thing I got from there was to pull the object from the
vector into a temperary object. That didnt work.
So, here is the code I have so far of making the temp object and
making sure it is actually pulling one out. I still connot figure out
how to access the getData() method.
Any hints are appreciated.
import java.util.Vector;
public class StackUser
{
public static void main(String argv[])
{
Vector vector = new Vector();
for (int i = 0; i < 100; i++)
vector.add(i, new StackNode());
System.out.println(vector.get(0));
Object tobj = vector.get(0);
System.out.println(tobj);
}
}
public class StackNode
{
private int value = 0;
public StackNode()
{
value = (int)(Math.random());
}
public int getData()
{
return value;
}
}
- Next message: Raymond DeCampo: "Re: Accessing a method inside of an object that is stored in a vector..."
- Previous message: IchBin: "Re: why does this program not end?"
- Next in thread: Raymond DeCampo: "Re: Accessing a method inside of an object that is stored in a vector..."
- Reply: Raymond DeCampo: "Re: Accessing a method inside of an object that is stored in a vector..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|