Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how do I split up a toString method so it appears over 2 lines?

843785Nov 9 2008 — edited Jan 29 2009
Bit of a newbie question, I have a program where the contents of a vector are printed out.

Problem is my toString method for the objects in it is quite long eg
public String toString() {
	 return "Name: " + name + " Room: " + room + " Subject: " + subject + " Time " + String.format(" %02d:%02d", getHours(), getMinutes());
     }
I will be adding the date as well, I want to split this up so when each element is output the time and date will appear a line below the name, room, subject,etc. to make the whole thing look a bit more tidy.

thanks,

Paul
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 26 2009
Added on Nov 9 2008
4 comments
230 views