π 2023λ 12μ 14μΌ
[java 9μΌμ°¨]
public class C1204_Constructor { public static void main(String[] args) { Calender cal1 = new Calender("2023", "12", "15"); Calender cal2 = new Calender("2023", "12"); Calender cal3 = new Calender("2023"); Calender cal4 = new Calender(); } static class Calender{ private String year; private String month; private String day; Calender(String year, String month, String day){ this.year = year; this.month = month; this.day = day; System.out.println("μ±"); System.out.println( this.year); System.out.println( this.month); System.out.println( this.day); } // λ©μλ μ€λ²λ‘λ©μ ν΅ν΄ κ°μ μ΄λ¦μ μμ±μ μμ±κ°λ₯ Calender(String year, String month){ this.year = year; this.month = month; } Calender(String year){ // this ν€μλλ₯Ό ν΅ν΄ ν΄λμ€λ΄ 맀κ°λ³μμ λ§λ μμ±μ νΈμΆ κ°λ₯ this(year,null, null); } Calender(){ } } }