162k views
0 votes
What is a Java constructor

User Davidcl
by
4.2k points

2 Answers

4 votes

A constructor in Java is a block of code similar to a method that's called when an instance of an object is created. Here are the key differences between a constructor and a method: A constructor doesn't have a return type. ... Unlike methods, constructors are not considered members of a class.

User Carlo Sirna
by
4.5k points
3 votes

A Java constructor is special method that is called when an object is instantiated.

User Theresa
by
4.8k points