我是新来的java,并且很难理解我在这里做错了什么。我仍然很难完全理解抽象类和接口,所以我认为这就是我的问题来自何处。试图将GregorianDate传递给Java中的构造函数
我想创建一个类,将允许我创建党的对象,我能够实例化除日期以外的所有变量。以下是我迄今为止:
public class Main {
public static void main(String[] args) {
...
Party joes = new Party("Joes party", "Joe", "Joe's Place",
new GregorianCalendar(2012,10,10));
joes.printParty();
}
}
public class Party {
//attributes of party
private String partyName;
private String partyHost;
private String location;
private GregorianCalendar partyTime;
public Party(String partyName, String partyHost, String location, GregorianCalendar partyTime){
this.partyName = partyName;
this.partyHost = partyHost;
this.location = location;
this.partyTime = partyTime;
}
}
当我打印出来,我得到:
"Joes party is going to be hosted by Joe at Joe's Place on:
java.util.GregorianCalendar[time=?,areFieldsSet=false,areAllFieldsSet=false,lenient=true..."
请参阅http://stackoverflow.com/questions/30434334/gregoriancalendar-outputs-the-date-is-java-util-gregoriancalendimeime-11415564 – Tunaki
对不起,如果我失去了一些东西,但我看到了这个答案,我想这是一个输出问题。我认为我的数据传递方式存在问题。 – Kronos
你为什么这么想? – Tunaki