摘要: interface Show{ public void show();}class A{ void f(Show s){ s.show(); }}public class Example5_17 { public static void main(String[] args) {A a=new A(); a.f(new Show(){ public void show(){ System.out.println("这是实现了接口的匿名类"); } });}}public class Example5_18{public static void main(String arg 阅读全文
posted @ 2013-04-25 21:19 张欣博同学 阅读(101) 评论(0) 推荐(0) 编辑
摘要: public class Example5_14 { public static void main(String args[]) {Pillar pillar;Geometry tuxing;tuxing=new Lader(12,22,100);System.out.println("梯形的面积"+tuxing.getArea());pillar=new Pillar(tuxing,58);System.out.println("梯形底的柱体的体积"+pillar.getVolume());tuxing=new Circle(10);System.o 阅读全文
posted @ 2013-04-20 17:48 张欣博同学 阅读(167) 评论(0) 推荐(0) 编辑
摘要: class B implements Computable{public int f(int x){ return x*x*x;} public int g(int x,int y){ return x*y;}}public class Example5_11 {public static void main(String[] args) {A a=new A(); B b=new B(); System.out.println(a.MAX); System.out.println(""+a.f(10)+""+a.g(12, 6)); System.ou 阅读全文
posted @ 2013-04-17 22:47 张欣博同学 阅读(143) 评论(0) 推荐(0) 编辑
摘要: class A{double n;int m;void f(){ System.out.printf("子类继承方法f(),n=%f,m=%d\n",n,m);}void g(){ System.out.printf("你好,n=%f,m=%d\n",n,m);}}class B extends A{int n=12;void g(){ System.out.printf("子类重写方法g(),n=%d,m=%d\n",n,m);}void cry(){ System.out.printf("子类新增的方法,n=%d,m=% 阅读全文
posted @ 2013-04-11 22:24 张欣博同学 阅读(165) 评论(0) 推荐(0) 编辑
摘要: class A{ public int f(int x,int y){ return x+y; } } class B extends A{ public int f(byte x,int y){ return x*y; } } public class Example5_5{ public static void main(String args[]){ int z=0; B b=new B(); z=b.f(10,10); System.out.println(z); z=b.f((byte)10,10); System.out.println(z); } } cla... 阅读全文
posted @ 2013-04-10 23:00 张欣博同学 阅读(313) 评论(0) 推荐(0) 编辑
摘要: class Father{private int moneyDollar=300;int moneyHK=200;int add(int x,int y){return x+y;}}class Son extends Father{int moneyRMB=800;public void changMoneyHK(int x){moneyHK=x;}public void changMoneyRMB(int x){moneyRMB=x;}int subs(int x,int y){return x-y;}}class GrandSon extends Son{ int multi(int x, 阅读全文
posted @ 2013-04-07 22:53 张欣博同学 阅读(190) 评论(0) 推荐(0) 编辑
摘要: public class Example4_18{public static void main(String args[]){char a[]={'a','b','c','D','E','F'};for(int i=0;i<a.length;i++){ if(Character.isLowerCase(a[i])){ a[i]=Character.toUpperCase(a[i]); } else if(Character.isUpperCase(a[i])){ a[i]=Character 阅读全文
posted @ 2013-03-31 10:56 张欣博同学 阅读(114) 评论(0) 推荐(0) 编辑
摘要: public class Rectangle{private double x,y,width,height;public void setX(double x){this.x=x;}public double getX(){return x;}public void setY(double y){this.y=y;}public double getY(){return y;}public void setWidth(double width){if(width<=0) this.width=0;else this.width=width;}public double getWidth 阅读全文
posted @ 2013-03-30 12:50 张欣博同学 阅读(277) 评论(0) 推荐(0) 编辑
摘要: public class Example4_15{private int money;Example4_15 (){money =2000;}private int getMoney(){return money;}public static void main(String args[]){Example4_15 exa=new Example4_15();exa.money=3000;int m=exa.getMoney();System.out.println("money="+m);}}class Employee{private double salary=180 阅读全文
posted @ 2013-03-26 22:59 张欣博同学 阅读(95) 评论(0) 推荐(0) 编辑
摘要: import java.text.SimpleDateFormat; import java.util.Date; public class Time { public static void main(String[] args) {SimpleDateFormat format = new SimpleDateFormat( "yyyy年-M月-d日 kk时:m分:ss秒 E "); String s = format.format(new Date()); System.out.println(s); }} 阅读全文
posted @ 2013-03-24 20:44 张欣博同学 阅读(180) 评论(0) 推荐(0) 编辑