If you write a constructor with parameters, then you need to declare the default one (if you want to use it)
class Person {
String name;
int age;
public Person(String name, int age){
this.name = name;
this.age = age;
}
}
You can't do this now:
Person p = new Person();
In order to use the "default" constructor (with no parameters) you will need to declare it:
class Person {
String name;
int age;
public Person(){
name = "Man With No Name"; //sometimes you will want to set the variables
age = 21; //to some default values
}
public Person(String name, int age){
this.name = name;
this.age = age;
}
}