두 클래스의 생성자는 Transactions
이며 첫 번째 생성자가 Label
개체이고 다른 하나가 Box
개체 인 마지막 인수가 다릅니다.두 클래스 인스턴스를 구별하는 방법
public class Transactions {
private String date;
private String kind;
private int employee;
private Label label;
private Box box;
public Transactions(String date, String kind, int employee, Box box) {
this.date = date;
this.kind = kind;
this.employee = employee;
this.box = box;
}
public Transactions(String date, String kind, int employee, Label label) {
this.date = date;
this.kind = kind;
this.employee = employee;
this.label = label;
}
...
}
내가 tr
입니다 클래스 Transactions
의 객체를 생성 한 말할 수 있습니다. 어느 것을 구분할 수 있습니까? Label
개체 또는 Box
개체를 가진 개체? 어떤 생성자가 호출 되었습니까?
어떤 생성자가 호출되었는지는 중요하지 않지만 '상자'또는 '라벨'이 null인지 여부는 확인할 수 있습니다. 좋은 디자인으로 간주 될지 여부는 다른 문제입니다. – Thomas