assignment

i need to make a call to my toString method which is my constructor class. i need to do this from my studentTest class, which is my driver class, how do i do this.

here is my toString:

public String toString(){

String str ="";

str +="Last Name: " + getLastName();

str +="First Name: " + getFirstName();

str +="Address: " + getAddress();

str +="City: " + getCity();

str +=" State: " + getState();

str +="Zip: " + getZip();

str +="Home Phone: " + getHomePhone();

str +="Cell Phone: " + getCellPhone();

str +="GPA: " + getGradePointAve();

return str;

}

how do i call toString from the studentTest class.

[1077 byte] By [redzone646a] at [2007-10-3 8:10:36]
# 1
[DELETED] due to double post.Message was edited by: Navy_Coder
Navy_Codera at 2007-7-15 3:15:00 > top of Java-index,Java Essentials,New To Java...
# 2
Double posted and answered here: http://forum.java.sun.com/thread.jspa?threadID=779794&messageID=4436682#4436682
floundera at 2007-7-15 3:15:00 > top of Java-index,Java Essentials,New To Java...
# 3
it doesnt work. i need to put the data in a concatenated string and return the string to the calling program.
redzone646a at 2007-7-15 3:15:00 > top of Java-index,Java Essentials,New To Java...
# 4
for some reason it is returning my default constructor, i dont want this, how do i make it so i call toString, not my default constructor?
redzone646a at 2007-7-15 3:15:00 > top of Java-index,Java Essentials,New To Java...
# 5
So whats your plan? Start another thread because you didn't get an adequate answer. Or perhaps you could reply to your last thread so people can see what answers have already been suggested.
floundera at 2007-7-15 3:15:00 > top of Java-index,Java Essentials,New To Java...
# 6

argh! string concatenation! don't do that, it hurts. use StringBuilder or StringBuffer. there's a very good chance your compiler is 'optimizing' your code to use StringBuilders here anyway, except that, in its infinite wisdom, there will be a new one for each concatenation. some optimization, huh?

what's a constructor class?

georgemca at 2007-7-15 3:15:00 > top of Java-index,Java Essentials,New To Java...