Java 생성자와 오버로딩 기본 예제

public class Television { 
    private int channel; 
    private int volume; 
    private boolean onOff; 
 
    Television(int channel, int volume, boolean onOff) { 
        this.channel = channel; 
        this.volume = volume; 
        this.onOff = onOff; 
    } 
 
    void print() { 
        System.out.println("채널은 " + channel + "이고 볼륨은" + volume + "입니다."); 
    } 
} 

 

public class TelevisionTest { 
    public static void main(String[] args) { 
        Television tv = new Television(4,5,true); 
        Television tv2 = new Television(5,7,false); 
 
        tv.print(); 
        tv2.print(); 
 
    } 
 
}