scjp 重载,请问这样写有什么问题??
public class wrenwren {
public static void main(String arg [])
{
wrenwren m = new wrenwren();
m.aaa(5.0);
}
public int aaa(int b)
{
System.out.println("bu xing!");
return 0;
}
void aaa(double b) throws Exception{
System.out.println("niu bi le !!!");
}
}
1。aaa()方法重载的对么?
2。为什么编译通过不了?
------解决方案--------------------
public class wrenwren {
public static void main(String arg[]) {
wrenwren m = new wrenwren();
try {
m.aaa(5.0);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public int aaa(int b) {
System.out.println("bu xing!");
return 0;
}
void aaa(double b) throws Exception {
System.out.println("niu bi le !!!");
}
}
1、对
2、因为你没有捕获异常。