package com.java1.day17;
public class EmployeeTest {
public static void main(String[] args) {
Date birth = new Date(1990, 1, 1);
Employee employee = new Employee("홍길동", birth);
System.out.println(employee);
}
}
class Employee {
private String name;
private Date birthDate;
public Employee(String name, Date birthDate) {
this.name = name;
this.birthDate = birthDate;
}
@Override
public String toString() {
return "Employee[name=" + name + ",birthDate=" + birthDate + "]";
}
}
class Date{
private int year;
private int month;
private int date;
public Date(int year, int month, int date) {
this.year = year;
this.month = month;
this.date = date;
}
@Override
public String toString() {
return "Date[year="+year+",month="+month+",date="+date+"]";
}
}
출력결과
Employee[name=홍길동,birthDate=Date[year=1990,month=1,date=1]]