How to return boolean true and false

Joined
Dec 4, 2022
Messages
2
Reaction score
0
Hey guys, i am currently studying a uni course, i need this method to take no parameters and returns true if the "room" is available and false if not. Room is available if its guest is an empty string.

Been trying to work it for days and no clue, any advise? I need to work it out on my own but some knowledge from an person on the outside could be a great help!

public boolean isAvailable(String guest) {
if (guest) {
return (true);
}
else {
return(false);
}
 
Joined
Mar 11, 2022
Messages
227
Reaction score
32
JAVA is a strict language. Strings are Strings. They can't be BOOLEAN. Your parameter "guest" is typed as string. So use String methods. if(guest) is a BOOLEAN method.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,058
Latest member
QQXCharlot

Latest Threads

Top