把你代码给运行下,是你方法体没有加上{}
class Arraytest_1 {
public void sum(int a, int b) {
int result = a + b;
System.out.println(result);
}
public void sum(double a, double b) {
double result = a + b;
System.out.println(result);
}
}
public class Arraytest {
public static void main(String[] args) {
Arraytest_1 acc = new Arraytest_1();
acc.sum(10, 15);
acc.sum(10.2, 15.3);
}
}
结果为:
25
25.5
|