【发布时间】:2014-01-08 13:35:54
【问题描述】:
这可能是一个非常菜鸟的问题,但我想我会在这里抓住机会。
所以基本上我必须做一个作业,它是这样的:
我必须创建一个构造函数,但变量“naam”不能为空或空(“”),变量“geboortedatum”不能是未来,也不能是与今天相同的日期和最后一个变量“boeken”与变量“naam”具有相同的要求(不能为空或“”)。
所以我的构造器是这样的,我只能编辑这部分,因为另一部分是我们老师给的,不能编辑。
if (this.naam == null || this.naam.equals("")) {
throw new IllegalArgumentException("Fill in name");
} else {
this.naam = naam;
}
Date vandaag = new Date();
if (this.geboorteDatum >= vandaag.getTime()) {
throw new IllegalArgumentException("Date must be in the past");
} else {
this.geboorteDatum = geboortedatum;
}
if (this.boeken == null || Arrays.toString(boeken).equals("")) {
throw new IllegalArgumentException("Can't be empty");
} else {
this.boeken = boeken;
}
它不断抛出我的第一个异常,我不知道为什么。这可能是一个非常愚蠢的问题,但我似乎无法找出原因。
任何帮助将不胜感激,在此先感谢
【问题讨论】: