Results 1 to 3 of 3
  1. #1
    Albert is offline Senior Member
    Join Date
    Jun 2007
    Posts
    114
    Rep Power
    0

    Default Problem with String Building

    I'm having trouble building strings while implementing a BST. For whatever reason which i cant figure out the stings are being printed in what i believe is hashcode. How can i get the string to print the "real string".

    My code basically looks like this

    Java Code:
    String bob = "";
    
    String bob += inOrderTrav(n.left);
    Where inOrderTrav is a private method which returns the string value of the item in the BST which corresponds to the BSTNode n.left.

    What am i missing here? Why is the string showing up as hashcode at System.out?

    Thanks
    Albert:rolleyes:

  2. #2
    bhatt.umang7 is offline Umang Bhatt
    Join Date
    Apr 2012
    Location
    Nadiad, Gujarat, India.
    Posts
    3
    Rep Power
    0

    Default Re: Problem with String Building

    probably you need to write the toString() method,

    please post more code.

  3. #3
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default Re: Problem with String Building

    Default toString method inherited from the Object class prints some sort of identifier followed by the hexadecimal representation of the objects hashcode. Try overriding toString().

    Gah, very old post. Bhatt.umang7, please don't bump threads that are nearly 5 years old.

Similar Threads

  1. help needed regarding tree building
    By invincible_me in forum New To Java
    Replies: 2
    Last Post: 08-12-2008, 02:44 PM
  2. String and Arry Problem
    By farakhkhan@yahoo.com in forum New To Java
    Replies: 3
    Last Post: 03-31-2008, 11:17 AM
  3. building a house
    By dc2acgsr99 in forum Java Applets
    Replies: 4
    Last Post: 03-08-2008, 12:18 AM
  4. Building a document from a DOM
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-03-2008, 10:22 AM
  5. problem with using string in if condition
    By sireesha in forum New To Java
    Replies: 2
    Last Post: 11-20-2007, 11:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •