What is a Java Constructor?
In Java, a constructor defines the code that is run when a new object is created.
To create a constructor, define a block of code with the same name as the class. For example, the following defines the construtor for a class called “Painting”.
To invoke a constructor, use the “new” keyword, followed by the name of the class.
When creating a Java constructor, remember the Java Constructor Rules.
Advertisement

