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 to print out a boolean variable :true or false?

807601Apr 23 2008 — edited Apr 24 2008
This is my output:
Inserting My
Inserting name
Inserting is
Inserting John
Inserting Latham
Inserting and
Inserting my
Inserting hobbies
Inserting include
Inserting films
Inserting music
Inserting electronics
Inserting and
Inserting computing
Searching for latham: //Here,in the correct ouput should out "true" or "false" after ":"
Searching for films: //same to last line
Searching for swimming: //....
Searching for fishing:
Searching for computing:
Searching for climbing:
Searching for paragliding:
Searching for Latham:

Code in main class:

public static void main(String[] args)
{


String [] insertStrings
= new String [] {"My", "name", "is", "John", "Latham", "and", "my",
"hobbies", "include", "films", "music", "electronics", "and", "computing" };



String [] findString
= new String[] {"latham", "films", "swimming", "fishing", "computing", "climbing",
"paragliding", "Latham" };


OBTComparable OBT = new OBTComparable() ;
for (int i=0; i<insertStrings.length; i++) {
OBT.insert(insertStrings);
System.out.println("Inserting" + insertStrings[i]);
}
for (int i=0; i<findString.length; i++) {
OBT.find( findString[i]);
System.out.println("Searching for " + findString[i] +":" ); // I tried add "empty",but can not compiled.
}
}
}


code in the method of a separate class:


public boolean find( Comparable findValue)
{
if(empty)
return false;
else if (findValue == value)
return true;
else if (findValue.compareTo(value)<=0)
return left.find(findValue);
else
return right.find(findValue);
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 22 2008
Added on Apr 23 2008
3 comments
311 views