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!

newline in toString()

807599Mar 8 2007 — edited Mar 8 2007
I have a TreeSet and I'm printing it using

System.out.println(myTreeSet)

I've overwritten the toString of the stored class to this:
public String toString()
    {
        return getAddress() + " : ?" + askingPrice + " : " + getClass() + System.getProperty("line.seperator");
    }
As you can see I'm trying to add in a newline at the end so each element of my TreeSet is printed on a newline. However, all this does is puts a null in place of the line seperator.

Is it possible to put the line break there, 'cos it's looking very messy ATM.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 5 2007
Added on Mar 8 2007
3 comments
230 views