Define a date class: including three member variables: year, month and day, and the method of displaying the date

*/

The code is as follows:

public class Demo { public static void main(String[] args) { Date date1=new Date(1994,5,22); date1.showInfo(); Date date2=new Date(); date2.year=1995; date2.month=6; date2.day=29; date2.showInfo(); }

}

//Date class:

Public class date {int year; int month; int day; / / construction method public date (int year, int month, int day) {this. Year = year; this. Month = month; this. Day = day;} Public date() {} public void showinfo() {system.out.println (year + year + month + day +);}}

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>