本帖最后由 yangshang1 于 2012-3-27 07:21 编辑
public class TestRuntimeException {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
Dog.add(0, 0);
}catch(Exception e)
{
//e.printStackTrace();
e.getMessage();
e.toString();
}
}
}
class Dog
{
private static int sum=0;
public static int add(int a,int b)
{
sum=a+b;
if(sum==0)
throw new RuntimeException("出错了");
return sum;
}
}
为什么打印不出来 |