Accessing Object Variables of an Object, stored in a Vector
How do I access the object variables of an object which is stored in a vector?
public class students
pubilc String Name;
public students(String aName)
this.Name = aName;
// somewhere in the main method
Vector allStudents = new Vector();
aStudent = new Students("Sanjay");
for (int k=0; k < allStudents.size(); k++)
Object m = allStudents.get(k);
This is throwing up an error "cannot resolve symbol variable Name".
Can anyone see where I am going wrong?
Thanks in advance,
with Java 5.0 it can be done different. I've not moved to it so I don't know the syntax off the top off my head.
That is is the correct solution!
Well sort of. It works for what you are doing. If you want to access more than one attribute or method, go ahead and cast it on the get from the Vector.
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center