摘要: 1 package hjwPackage; 2 3 public class hjwClass { 4 public static int add(int i,int j){ 5 return i+j; 6 } 7 public static int sub(int i,int j){ 8 return i-j; 9 }10 public static int mul(int i,int j){11 return i*j;12 }13 public static int div(int ... 阅读全文
posted @ 2012-03-11 21:01 谈笑风生膜法师 阅读(190) 评论(0) 推荐(0)
摘要: 1 class MyException extends Exception{ 2 public MyException(String msg){ 3 super(msg); 4 } 5 } 6 public class ThrowsDemo { 7 public static void main(String args[]){ 8 try{ 9 throw new MyException("自定义异常"); 10 }catch (Exception e){11 ... 阅读全文
posted @ 2012-03-11 19:36 谈笑风生膜法师 阅读(248) 评论(0) 推荐(0)
摘要: 1 class Math{ 2 public int div(int i,int j) throws Exception{ 3 System.out.println("========计算开始======="); 4 int temp=0; 5 try{ 6 temp=i%j; 7 } catch(Exception e){ 8 throw e; 9 } finally{10 System.out.println("=========... 阅读全文
posted @ 2012-03-11 19:29 谈笑风生膜法师 阅读(176) 评论(0) 推荐(0)
摘要: View Code 1 class Math{ 2 public int div(int i,int j) throws Exception{ 3 int t=i/j; 4 return t; 5 } 6 } 7 public class ThrowsDemo { 8 public static void main(String args[]) throws Exception{ 9 Math m=new Math();10 System.out.println("出发操作:"+m.div(10,2));... 阅读全文
posted @ 2012-03-11 19:18 谈笑风生膜法师 阅读(262) 评论(0) 推荐(0)