-1
import java.util.*;
import java.io.*;
class Main {
public static int TimeConvert(int num) {
int t;int n;
t = num % 60;
n = num/60;
return n + ":" + t;
}
public static void main (String[] args) {
Scanner s = new Scanner(System.in);
System.out.print(TimeConvert(s.nextLine()));
}
}
我正在尋找在屏幕上使用返回方法輸出答案num/60與a:然後輸出答案num%60.它會看起來像這樣..(用戶輸入號碼124)然後輸出2:4(小時:分鐘)。它工作,如果我System.out但不是當我返回它。我得到的錯誤信息......不兼容的類型:字符串不能轉換爲int
Main.java:11: error: incompatible types: String cannot be converted to int
return n + ":" + t;
^
1 error
我怎麼能返回(INT):(INT)?