
March 3rd, 2007, 08:34 PM
|
|
Registered User
|
|
Join Date: Jan 2007
Posts: 17
Time spent in forums: 5 h 7 m 59 sec
Reputation Power: 0
|
|
|
Stuck with "need return statement" error, but my returns are fine
Hello peeps, thanks for viewing and taking the time out to help me.
Code:
public static int compareTime(String time1, String time2){
String firstLine = time1;
StringTokenizer firstNumTime = new StringTokenizer(firstLine, ":");
int realNumTime1 = Integer.parseInt(firstNumTime.nextToken());
String secondLine = time2;
StringTokenizer secondNumTime = new StringTokenizer(secondLine, ":");
int realNumTime2 = Integer.parseInt(secondNumTime.nextToken());
if( (realNumTime1 - realNumTime2) < 0)
return -1;
if( (realNumTime1 - realNumTime2) > 0)
return 1;
}// compareTime
this method is suppose to read in 2 strings
"12:57" and "2:45"
the method then takes in the first number before the ":" and converts it into an integer.
The return statements are clearly stated, but when compiled I get
"missing return statement"
}//compareTime
1 error
|