我有一个类的两个构造函数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;
}
...
}
Run Code Online (Sandbox Code Playgroud)
比方说,我创建类的对象Transactions
是tr
.我该如何区分它是哪一个?一个与Label
对象或一个与Box
对象?哪个构造函数被调用?