-
get output from vector
Hello all,
I have a class called student which includes 3 string variables: fName, lName, and gpa.
I have a vector called "s"
I read a text file into "s" using s.add(new Student(fname, lname, gpa))
The input goes fine, but when I do s.get(i), I am presented with student@memoryLocation.
How do I go about actually getting the s.Student(fname, lname, gpa)?
Thanks for your help!
-
you've got the Student object. The problem is that you are tr ying to print the Student object, and Student has not yet overridden the toString() method.
so, if you want to see student with:
Code:
System.out.println(s.get(i));
then Student needs a toString override.
If you want to check that you in fact have a student object, try calling one of its getter methods (I assume it has get and possibly set methods?).