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

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 阅读(159) 评论(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)
 
 

公告


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