Constructors in Java


Constructors are special methods invoked when an object is created.

Source Code

public class Car {
    public Car() {
        System.out.println("A car is created.");
    }
    public static void main(String[] args) {
        Car myCar = new Car();
    }
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments