疯狂JAVA讲义——第二章练习题

第一题

文档注释可以在 类、接口、方法、成员变量、构造器和内部类之前;
并且使用javadoc命令工具进行生成;
有一些标记比如:
1. 在类或者接口文档中:@deprecated,@see,@author,@version
2. 方法或者构造器文档注释中:@deprecated,@param,@return,@throws,@exception
3. 成员变量的文档注释当中:@see,@deprecated
并且由于javadoc工具不会提取@author,@version所以如果需要提取这两个标记那么需要在使用javadoc工具时候指定 -author ,-version。

/**
*   Describtion:
*   @author: tris_tan
*   @version:   1.0
*/
class   Teacher
{
    static int teacherNum   =   0;
    private String name;
    private int age;
    private String project;

    public Teacher(String   name,   int age, String project)
    {
        this.name   =   name;
        this.age = age;
        this.project = project;
    }
    public void show()
    {
        System.out.println("This student name   is "+name   +" , and "+ age +" years old . Her/Him project is   "+ project +"   ." );

    }
}
class   Student
{
    static int stuNum   =   0;
    private String name;
    private int age;
    public Student(String   name,   int age)
    {
        this.name   =   name;
        this.age = age;
    }
    public void show()
    {
        System.out.println("This student name   is "+name   +" , and "+ age+"   years   old ." );

    }
}
class   ClassRoom
{

    static int roomNum = 0;
    private String roomName;
    private int roomSeats;
    public ClassRoom(String name,   int seats)
    {
        this.roomName   =   name;
        this.roomSeats = seats;
    }
    public void show()
    {
        System.out.println("This is "+roomName+" room   ." +"   And this room   can contain "+ roomSeats+" people." );

    }
}
public class test{
        public static   void main   (String[]   args)
        {
            Teacher tea =   new Teacher("lili", 25 , "math" );
            Student stu =   new Student("max",12);
            ClassRoom   room = new ClassRoom("B521",102);
            tea.show();
            stu.show();
            room.show();

        }

}

生成的api文档大致如下:
这里写图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值