?? people.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 + -