📄 program10_5.java
字号:
import java.text.*; // needed for formatting
public class Date
{
// class variable declaration section
private int month;
private int day;
private int year;
// class method definition section
public Date(int mm, int dd, int yyyy) // constructor
{
this.month = mm;
this.day = dd;
this.year = yyyy;
}
public void showdate()
{
DecimalFormat df = new DecimalFormat("00");
System.out.print(df.format(this.month)
+ '/' + df.format(this.day) + '/'
+ df.format(this.year % 100));
}
public static void main(String[] args)
{
Date a = new Date(04,01,1999); // create two Date objects
Date b = new Date(12,18,2001);
System.out.print("\nThe date stored in a is originally ");
a.showdate(); // display the original date
a = b; // assign b's value to a
System.out.print("\nAfter assignment the date stored in a is ");
a.showdate(); // display a's values
System.out.println();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -