Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Traversing a binary tree while looking for a string

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    26
    Thanks
    3
    Thanked 1 Time in 1 Post

    Default Traversing a binary tree while looking for a string

    I am unsure how to look to see if the string in the current node is the same as the message I am looking for.I thought about using compareTo(), but then I wasn't sure if what would work or not. So far I have:


    public void searchRooms(MountainCave theParent, String name, String message){
            if(theParent == null){
                return false;
            }else if(theParent.String.compareTo(message){
                return true;
            }//else if( )
     
        }


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Traversing a binary tree while looking for a string

    Did it work?
    What happens?
    What does the API say about comparing Strings?

Similar Threads

  1. Binary Tree ( Family Tree)
    By tommyacton in forum Algorithms & Recursion
    Replies: 0
    Last Post: March 23rd, 2013, 11:40 PM
  2. NullPointerException when comparing string in binary tree
    By tetkun in forum What's Wrong With My Code?
    Replies: 4
    Last Post: March 19th, 2013, 07:57 PM
  3. Binary Search Tree inorder tree traversal
    By Maukkv in forum What's Wrong With My Code?
    Replies: 17
    Last Post: January 26th, 2013, 05:28 PM
  4. [SOLVED] Traversing a tree
    By IAmHere in forum Algorithms & Recursion
    Replies: 3
    Last Post: June 19th, 2011, 10:47 AM
  5. Data Structures(Binary Search Tree to AVL Tree)ASAP
    By jfAdik in forum Algorithms & Recursion
    Replies: 2
    Last Post: April 5th, 2010, 04:58 AM