} } Note that the class is having default package visibility. Then What is the idea behind the public constructor when the class itself is not visible outside the package? Can anybody any uasge or neccessity of above public constructor?
But the classes within the package can instantiate this class. If the constructor were private even classes within the default package cant instantiate this class.
What is the idea behind the public constructor when the class itself is not visible outside the package? Can anybody any uasge or neccessity of above public constructor?
There is no usage of a public constructor in a default class. And there is no idea behind it. It's just bad design. The constructor should be default as well, but public doesn't do any harm, just puzzles people. The only situation where you put an access level to a constructor is when you mark it private to hinder other classes to instantiate it.