Class Definition
package aa;
public class abc {
public String month;
public int day;
public int year;
public void writeOutput() {
System.out.println(month + " " + day + " ," + year);
}
public void makeItNewYears(){
month="January";
day = 1;
System.out.println(month + " " +day +" , "+year);
}
}
package aa;
public class def
{
public static void main(String[] args)
{
abc date1, date2;
date1 = new abc();
date2 = new abc();
date1.month = "December";
date1.day = 31;
date1.year=2007;
System.out.println("date1:");
date1.writeOutput();
date1.makeItNewYears();
date2.month="Jully";
date2.day=4;
date2.year=1776;
System.out.println("date2");
date2.writeOutput();
date2.makeItNewYears();
}
}
結果
0 Comments:
Post a Comment
<< Home