上一页 1 ··· 14 15 16 17 18

java例程练习(数三退一[用数组模拟])

摘要: public class ThreeOut { public static void main(String[] args) { boolean[] arr = new boolean[500]; for(int i = 0; i 1) { if(arr[index] == true) { countNum ++; if(countNum == 3) { countNum = 0; arr[index] = false; leftCount --; } } index ++; if(index == arr.... 阅读全文
posted @ 2012-04-29 16:02 Yours风之恋 阅读(147) 评论(0) 推荐(0) 编辑

java例程练习(对象类型数据的排序)

摘要: public class TestSort { public static void main(String[] args) { Date[] days = new Date[5]; days[0] = new Date(2004, 8, 6); days[1] = new Date(2007, 4, 6); days[2] = new Date(2007, 4, 9); days[3] = new Date(2004, 4, 6); days[4] = new Date(2004, 4, 5); bubbleSort(days); for(int i = 0; i ... 阅读全文
posted @ 2012-04-29 15:23 Yours风之恋 阅读(157) 评论(0) 推荐(0) 编辑

java例程练习(控制台参数与基础数据类型的包装类)

摘要: public class Test { public static void main(String[] args) { if(args.length < 3) { System.out.println(" ==!"); System.exit(-1); } double d1 = Double.parseDouble(args[0]); double d2 = Double.parseDouble(args[2]); double d = 0; if(args[1].equals("+")) { d = d1 + d2; } else if(ar 阅读全文
posted @ 2012-04-29 13:49 Yours风之恋 阅读(130) 评论(0) 推荐(0) 编辑

java例程练习(一维数组)

摘要: public class Test { public static void main(String[] args) { int a[] = { 3, 9, 8}; //静态初始化 Date days1 [] = { new Date(1, 4, 2004), new Date(2, 4, 2004), new Date(3, 4, 2004) }; //动态初始化 Date [] days2 = new Date[3]; for (int i = 0; i < 3; i++) { days2[i] = new Date(2004, 5,... 阅读全文
posted @ 2012-04-29 11:05 Yours风之恋 阅读(172) 评论(0) 推荐(0) 编辑

java例程练习(自定义异常处理)

摘要: public class Test { public void regist(int num) throws MyException { if(num < 0) { throw new MyException("人数为负值,不合理", 3); } System.out.println("登记人数" + num); } public void manager(int k) { try { regist(k); } catch(MyException me) { System.out.println("登记出错,出错类型:" + m 阅读全文
posted @ 2012-04-22 22:11 Yours风之恋 阅读(139) 评论(0) 推荐(0) 编辑

java例程练习(接口interface)

摘要: interface Valuable { public double getMoney();}interface Protectable { public void beProtected();}interface A extends Protectable { void m();}abstract class Animal { private String name; abstract void enjoy(); public void setName(String name) { this.name = name; } public String getName() { return... 阅读全文
posted @ 2012-04-22 18:21 Yours风之恋 阅读(174) 评论(0) 推荐(0) 编辑

java例程练习(多态/动态绑定/迟绑定)

摘要: // 实现多态三个条件:// 1,继承// 2,父类引用指向子类对象// 3,重写public class Test { public static void main(String[] args) { Cat c = new Cat("KIKI", "Blue"); Dog d = new Dog("Tom", "Black"); Lady l1 = new Lady("Sheery", c); Lady l2 = new Lady("Dianl", d); l1.myPe 阅读全文
posted @ 2012-04-22 15:11 Yours风之恋 阅读(137) 评论(0) 推荐(0) 编辑

java例程练习(对象转型及instanceof关键字)

摘要: public class Test { public static void main(String[] args) { Animal a = new Animal("name"); Cat c = new Cat("Tom", "Blue"); Dog d = new Dog("Pipi", "Black"); System.out.println(a instanceof Animal); System.out.println(c instanceof Animal); System.out 阅读全文
posted @ 2012-04-22 14:07 Yours风之恋 阅读(166) 评论(0) 推荐(0) 编辑
上一页 1 ··· 14 15 16 17 18