In this program, You will learn how to implement parameterized constructor in java.
Main(int a) {
//statement
}
class Main {
int x;
Main(int a) {
x = a;
System.out.println("Parameterized Constructor is called here");
}
void display() {
System.out.println("The Value of x is:" + x);
}
public static void main(String args[]) {
Main t = new Main(10);
t.display();
}
}
Parameterized Constructor is called here
The Value of x is:10