How to Use Default Constructor in Java


In this example we will show how to use default constructor in Java.

Source Code

package com.beginner.examples;

public class ConstructorExample {

	public ConstructorExample(){
        System.out.println("Default constructor");
    }
     
    public static void main(String a[]){
    	ConstructorExample o1 = new ConstructorExample();
    }
}

Output:

Default constructor
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments