Though itz not a compiler error, for the class and the method to have the same name, y is it not preferred?(the editor says"method has a constructor name") can someone explain me this?
posted 11 years ago
Constructor is a method that has the same name as the class name. So if you are having a method with same name as the class name but with a return type, it decreases the clarity of the code and leads to confusion so it's better to avoid that.