ITeye博客

Java

共 2 篇文章

Java 自定义异常类

public class ExceptionTest { public static void main(String [] args){ int result; Test test = new Test(); try{ //result = test.devide(10, 0); result = test.devide(10, -2); //result = test.devide(10, 2); }catch (DevidedByMinusException e) { System.out.println(e.getMessage()+"; the devisor is "+e.get…

2013-02-22 10:58 · Java

Java趣味短码

原文: http://www.ituring.com.cn/article/27186#jtss-tqq 今天跟公司的童鞋聊天的时候,谈到了关于短码和代码的精简的方式,所以整理出来。 需求很简单。 首先定义一个类 classItem{publicint key;publicint l;publicint r;}; 然后主函数的场景大概是这样 publicstaticvoid main(String[] args){Item x; x =newItem(); x.key =1; x.l =10; x.r =20;int i =0;if(x.key > i){ i = x.l;}else{ i …

2013-01-24 21:45 · Java