I was practicing dome Java OO principles, when I encountered with this. I create to POJOs and when trying to make objects from it, if an empty constructor isn't defined, it wont compile.
I find this weird because I used to do that and the JVM included a default one for me. Is it new in Java 7? Am I missing something?
Here is the sample code I made
public class Dog {
String name;
String race;
int age;
/*
public Dog() {
If this isn't included, it doesn't compile if I try to
create no-args objects.
}*/
public Dog (String _name) {
this.name = _name;
}
public Dog (String _name, String _race) {
this.name = _name;
this.race = _race;
}
public Dog (String _name, String _race, int _age) {
this.name = _name;
this.race = _race;
this.age = _age;
}
}