最赞回答 / 无说有听mk
sum()方法需要返回int数值,而return score1+score2,正是返回了(score1+score2)这个int值。sum()是静态方法,所以在main里也可以这么输出System.out.println("总分:" + sum());HelloWorld.sum()你这么写,并没有接受sum方法返回值,你要不这样接收返回值:int what = sum();要么直接输出System.out.println("总分:" + sum());
2020-04-16
最赞回答 / qq_慕尼黑5385346
int x;//你说的1或者2.while(true){try{x=input.nextInt();if(x==1||x==2){break;}else{System.out.println("输入有误,请重新输入");continue;}}catch(Exception e){ System.out.println("输入报错,请重新输入"); input.next(); continue;}}
2020-04-12
最赞回答 / weixin_慕无忌5542348
第一张图Tepphone phone=new Telphone(),new后面不能接Telphone(),因为Telphone类里只有抽象的sendMessage方法,并没有具体实现,当你实例化一个Telphone的对象时是没有具体的sendMessage方法给你调用的,new后面应该接SmartPhone()或者CellPhone(),这两个类里有具体实现的sendMessage方法。第二张图Telphone前面应该是class而不是interface吧。即将public interface Telph...
2020-04-08