• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
wangchunmei
博客园 首页 新随笔 联系 订阅 订阅 管理
上一页 1 2 3 4 下一页

2013年4月14日

关键字super
摘要: class A{int x,y;A(){x=100;y=200;}A(int x,int y){this.x=x;this.y=y;}}class B extends A{int z;B(int x,int y){super(x,y);z=300;}B(){super();z=800;}public void f(){System.out.printf("x=%d,y=%d,z=%d\n",x,y,z);}}public class Example5_6{public static void main(String arg[]){B b1=new B(10,20);b1.f 阅读全文
posted @ 2013-04-14 18:36 wangchunmei 阅读(140) 评论(0) 推荐(0)
 
成员变量的隐藏和方法重写(Example5_3/Example5_4/Example5_5)
摘要: class A{public double y=11.456789;public void f(){y=y+1;System.out.printf("y是double型的变量,y=%f\n",y);}}class B extends A{int y=0;public void g(){y=y+100;System.out.printf("y是int型的变量,y=%d\n",y);}}public class Example5_3{public static void main(String arg[]){B b=new B();b.y=200;b.g() 阅读全文
posted @ 2013-04-14 18:34 wangchunmei 阅读(253) 评论(0) 推荐(0)
 
Example5_2(子类对象的构造方法)
摘要: class A{private int x=10;protected int y=20;void f(){y=y+x;System.out.printf("x=%d,y=%d\n",x,y);}}class B extends A{void g(){y=y+1;System.out.printf("y=%d\n",y);}}public class Example5_2{public static void main(String arg[]){B b=new B();b.g();b.f();b.g();}} 阅读全文
posted @ 2013-04-14 18:30 wangchunmei 阅读(152) 评论(0) 推荐(0)
 
字符数组中的大小写字母变换/使用对象数组
摘要: public class Example4_18{public static void main (String arg[]){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.toLo 阅读全文
posted @ 2013-04-14 18:24 wangchunmei 阅读(458) 评论(0) 推荐(0)
 
 

2013年3月31日

私有变量和私有方法(Example4_15和Example4_16)
摘要: public class Example4_15{private int money;Example4_15(){money=2000;}private int getMoney(){return money;}public static void main(String arg[]){Example4_15 exa=new Example4_15();exa.money=3000;int m=exa.getMoney();System.out.println("money="+m);}}class Employee{ private double salary=1800; 阅读全文
posted @ 2013-03-31 08:43 wangchunmei 阅读(163) 评论(0) 推荐(0)
 
 

2013年3月23日

Example4_11(关键字this)
摘要: public class Tom{int leg;Tom(int n){this.cry();leg=n;this.cry();}void cry(){ System.out.println("我是Tom,我现在有"+leg+"条腿");}public static void main(String args[]){Tom cat=new Tom(4);}} 阅读全文
posted @ 2013-03-23 20:52 wangchunmei 阅读(157) 评论(0) 推荐(0)
 
Example4_10(方法重载)
摘要: class People{double getArea(double x,double y){return x*y;}int getArea(int x,double y){return(int)(x*y);}double getArea(float x,float y,float z){return(x*x+y*y+z*z)*2.0;}}public class Example4_10{public static void main(String arg[]){People zhang=new People() ;System.out.println("面积:"+zhan 阅读全文
posted @ 2013-03-23 12:18 wangchunmei 阅读(130) 评论(0) 推荐(0)
 
参数传值(Example4_7.Example4_8,Example4_9)
摘要: class Tom{void f(int x,double y){x=x+1;y=y+1;System.out.printf("参数x和y的值分别是:%d,%3.2f\n",x,y);}}public class Example4_7{public static void main(String arg[]){int x=10;double y=12.58;Tom cat=new Tom();cat.f(x,y);System.out.printf("main方法中x和y的值仍然分别是:%d,%3.2f\n",x,y);}}class Jerry{int 阅读全文
posted @ 2013-03-23 12:02 wangchunmei 阅读(317) 评论(0) 推荐(0)
 
 

2013年3月22日

Example4_6(用类名调用类方法)
摘要: class Computer{double x,y;static double max(double a,double b){return a>b?a:b;}}class Example4_6{public static void main(String arg[]){double max=Computer.max(12,45);System.out.println(max);}} 阅读全文
posted @ 2013-03-22 22:01 wangchunmei 阅读(127) 评论(0) 推荐(0)
 
 

2013年3月21日

成员变量(对象共享类变量及常量的用法)Example4_4//Example4_5
摘要: class Lader{double above,height;static double bottom;void setAbove(double a){above=a;}void setBottom(double b){bottom=b;}double getAbove(){return above;}double getBottom(){return bottom;}}class Example4_4{public static void main(String arg[]){Lader.bottom=60;Lader laderOne,laderTwo;System.out.printl 阅读全文
posted @ 2013-03-21 20:29 wangchunmei 阅读(190) 评论(0) 推荐(0)
 
 
上一页 1 2 3 4 下一页

公告


博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3