⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 people.java

📁 java 经典实例 java学习 实例 这个对于java确实很有帮助
💻 JAVA
字号:
import Mypackage.NewDate;                //引用Mypackage包中的NewDate类
public class People
{
    private String name;
    private NewDate  birth;
    public static void main(String args[])
    {
        People a = new People("Wangli",1981,2,14);
        a.output();
    } 
    public People(String n1,NewDate d1)
    {
        name = n1;
        birth = d1;
    }
    public People(String n1,int y,int m,int d)
    {
        this(n1,new NewDate(y,m,d));
    }
    public People()
    {
        this("",new NewDate());
    }
    public int age()                                 //计算年龄
    {
        return  NewDate.thisyear() - birth.year();   //获得年份
    }
    public void output()
    {
        System.out.println("name : "+name);
        System.out.println("birth: "+birth.toString());
        System.out.println("age  : "+age());
    } 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -