Parameterized Constructor, constructor present in same class
Java Programming Language Class, Object and Methods in java (Article) Class, Object and Methods in java (Program)
926Program:
class ParameterizedConstructor{ int rollno; String name; // it is Parameterized Constructor ParameterizedConstructor(int i,String n){ rollno = i; name = n; System.out.println(rollno+" "+name); } public static void main(String args[]){ ParameterizedConstructor s1 = new ParameterizedConstructor(1,"Rahim"); ParameterizedConstructor s2 = new ParameterizedConstructor(2,"Ram"); } }
Output:
1 Rahim 2 Ram Press any key to continue . . .
This Particular section is dedicated to Programs only. If you want learn more about Java Programming Language. Then you can visit below links to get more depth on this subject.