Guys Im new to java - Trivial question
public boolean isBooked(int day,int time){
StringTokenizer tk = new StringTokenizer(bookings);
while (tk.hasMoreTokens()){
String str = tk.nextToken();
if (str.startsWith(day+"^"+time)){
return true;}
else{
return false;}
}
}
1 error found:
File: F:\UTM\csc108h\Test\Car.java [line: 63]
Error: missing return statement
[397 byte] By [
salonaha] at [2007-10-2 4:45:58]

The problem is both of your return statements are inside the while loop.Your code doesn't make sense anyway. Inside the while loop you have an if/else statement which means the "loop" will only ever execut once anyway, so the while loop isn't even needed.
Thanks all - This finally works!
<code>public boolean isBooked(int day,int time){
StringTokenizer tk = new StringTokenizer(bookings);
while (tk.hasMoreTokens()){
String str = tk.nextToken();
if (str.startsWith(day+"^"+time)){
return true;
}
}
return false;
}
</code>