| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 537 人关注过本帖
标题:这段代码请赐注释
只看楼主 加入收藏
学编程啊
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:66
专家分:110
注 册:2012-7-25
结帖率:100%
收藏
已结贴  问题点数:8 回复次数:1 
这段代码请赐注释
书上的代码,没注释,看不太懂
麻烦大家加个注释,谢谢
最好能详细点。。。
package com.lzw;
public class U3 {
    private float height;
    private float width;
    public U3(float height,float width){
        this.height=height;
        this.width=width;
    }
    public float square(){
        return height*width;
    }
    public static void main(String args[]){
        U3 u=new U3(3.5f,4.5f);
        System.out.println(u.square());
    }
}
搜索更多相关主题的帖子: static void private package public 
2013-03-09 17:36
不玩虚的
Rank: 9Rank: 9Rank: 9
来 自:四川
等 级:贵宾
威 望:10
帖 子:331
专家分:1301
注 册:2012-12-9
收藏
得分:8 
package com.lzw;//引入的包
public class U3 {//定义了一个类,类名U3,公共类
    private float height;//定义2个私有变量类型为float
    private float width;
    public U3(float height,float width){//定义了一个类的带参数的构造函数,类型公共的
        this.height=height;//通过this指针,访问类的私有数据成员
        this.width=width;
    }
    public float square(){//定义了一个类的函数或方法,访问权限公有的
        return height*width;
    }
    public static void main(String args[]){
        U3 u=new U3(3.5f,4.5f);//定义了一个类的对象,并通过构造函数赋值
        System.out.println(u.square());//类的对象调用类的方法
    }
}

同学习......同进步....你帮我......我帮你.....上善若水.....
2013-03-09 19:23
快速回复:这段代码请赐注释
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013274 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved