Tuesday, 20 August 2013

Why Default constructor need to declare in POJO file which has Parameterized Constructor while instantiating Object?

Why Default constructor need to declare in POJO file which has
Parameterized Constructor while instantiating Object?

Suppose I have one POJO class User with a constuctor public User(int id,
String name){...}. But when I instantiate the User object like User u=new
User() with no parameter Eclipse gives error like The constructor User()
is undefined. But it works fine when I have no parameterized Constructor.
Can someone please explain why It requires to define default constructor?

No comments:

Post a Comment