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.
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL