Parameterized Constructor, constructor present in same class, with method usefull example

Java Programming Language Class, Object and Methods in java (Article) Class, Object and Methods in java (Program)

992

Program:

 class ClassConstructor{
      int  value1;
      int  value2;

      ClassConstructor(){
         value1 = 10;
         value2 = 20;
         System.out.println("Inside Constructor");
     }

     public void display(){
		System.out.println("Inside Method");
        System.out.println(" Value1 === "+value1);
        System.out.println("Value2 === "+value2);
    }

   public static void main(String args[]){
       ClassConstructor d1 = new ClassConstructor();
      d1.display();
  }
}

  

Output:

Inside Constructor
Inside Method
 Value1 === 10
Value2 === 20
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.