I should check if the values entered while creating the object are incorrect,for example invalid dates like 30.02.2021 in date object. I want to give an error message and close the program using the exit () command, should i do the value checks in the constructor or after the object is created?
public Date(int day, int month, int year) {
if(check(day,month,year)) {
this.day = day;
this.month = month;
this.year = year;
}
else {
System.out.println("Error:Invalid Date!,Please check input file and try again!");
System.exit(1);
}
}