--%>

Explain Constructor

Constructor: A constructor is automatically called whenever an instance of its class is formed. A constructor always has similar name as its class, and encompass no return type. For example:

public class Ship {
    public Ship(String name){
        ...
    }
    ...
}

The class with no explicit constructor consists an implicit no-arg constructor that takes no arguments and contains an empty body.

   Related Questions in Programming Languages