Java J2EE Spring What is the use of Constructor.?


A constructor is automatically called and executed at the time of creating an object.


  • It  is used to initialize the instance variables of a class.
  • It is used to create an Object of a class.


Example:



[code]

public class Con{
   Con(){
          ----
         -----
       }
}

[/code]