I am just learning about objects and class definitions. This assignment is meant to create an object named birthday and print it in a reader friendly format. When I run it, it prints "moredates.Date@15db9742" when it should be printing "4/21/1999".
Below is my Date class.
package moredates;
public class Date {
int year, month, day;
public Date(){
this.year=0;
this.month=0;
this.day=0;
}
public Date(int year, int month, int day){
this.year=year;
this.month=month;
this.day=day;
}
public static void printDate (Date d){
System.out.println(d.month + "/" + d.day + "/" + d.year);
}
}
And here is my main class which is in a different file, but in the same package.
package moredates;
public class MoreDates {
public static void main(String[] args) {
Date birthday= new Date();
birthday.month=4;
birthday.day=21;
birthday.year=1999;
Date d=birthday;
System.out.print(d);
}
}