首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

scjp 重载,请教这样写有什么有关问题?

2012-03-23 
scjp 重载,请问这样写有什么问题??public class wrenwren {public static void main(String arg []){wrenw

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、因为你没有捕获异常。

热点排行
Bad Request.