mrAKU
mrAKU

Reputation: 11

Why does IntelliJ want me to construct an empty constructor?

intelliJ message

I am new to Java and I understand constructors(I guess), but why does my code does not work until I construct an empty constructor? When I already have a constructor with parameters etc of that class.

Upvotes: 1

Views: 651

Answers (1)

Md Golam Rahman Tushar
Md Golam Rahman Tushar

Reputation: 2375

Because you don't have a constructor with no argument at your class. That's why when you are trying to create an instance using the no argument constructor it showing you the error.

Note that, If you don't define any constructor then the class have a default constructor with no parameter. But if you do declare a constructor then there is no default constructor, only the ones you define.

Hope this will clear your confusion.

Upvotes: 1

Related Questions