I try to compare the default constructor in Java and C++.
In C++, a default constructor has one of the two meansings
1) a constructor has ZERO parameter
Student()
{ //etc...
}
2) a constructor that all parameters have default values
Student(int age = 10, String name = "Joe")
{ //etc...
}
However, In Java, default constructor means a constructor has ZERO parameter only.
Student()
{ //etc...
}
The following will yield compile errors
Student(int age = 10, String name = "Joe")
{ //etc...
}
Any ideas why Java doesn't support that?
Please advise. Thanks!!
In C++, a default constructor has one of the two meansings
1) a constructor has ZERO parameter
Student()
{ //etc...
}
2) a constructor that all parameters have default values
Student(int age = 10, String name = "Joe")
{ //etc...
}
However, In Java, default constructor means a constructor has ZERO parameter only.
Student()
{ //etc...
}
The following will yield compile errors
Student(int age = 10, String name = "Joe")
{ //etc...
}
Any ideas why Java doesn't support that?
Please advise. Thanks!!
Comment