The method printf(String, Object…) in the type PrintStream is not applicable for the arguments (String, void)
它给了我一个错误信息说
The method printf(String, Object...) in the type PrintStream is not applicable for the arguments (String, void)
nbsp;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | public class project { public static void main(String[] args){ duo duoObject = new duo(); duo duoObject1 = new duo(5); duo duoObject2 = new duo(2,6); duo duoObject3 = new duo(3,7,5); System.out.printf("%s ", duoObject.militaryTime()); System.out.printf("%s ", duoObject1.militaryTime()); System.out.printf("%s ", duoObject2.militaryTime()); System.out.printf("%s ", duoObject3.militaryTime()); } } public class duo { private int hour; private int minute; private int second; public duo(){ } public duo(int h){ setHour(h); } public duo(int h, int m){ setHour(h); setHour(m); } public duo(int h, int m, int s){ setHour(h); setHour(m); setHour(s); } public void setHour(int h){ hour = ((h>=0 && h<24)? h : 0); } public void setMinute(int h){ minute = ((h>=0 && h<60)? h : 0); } public void setSecond(int h){ second = ((h>=0 && h<60)? h : 0); } public int getHour(){ return hour; } public int getMinute(){ return minute; } public int getSecond(){ return second; } public void militaryTime(){ System.out.printf("%02d:%02d:%02d", getHour(), getMinute(), getSecond()); } } |
也许您希望
1 2 3 |