In this example, we may see how to use parameterized Constructor in Java.
Source Code
package com.beginner.examples;
public class ParameterizedConstructorExample {
public ParameterizedConstructorExample(String str){
System.out.println("Constructor with String object: " + str);
}
public static void main(String a[]){
ParameterizedConstructorExample p = new ParameterizedConstructorExample("java");
}
}
Output:
Constructor with String object: java