Hello friends.. plz, wt the most importance advantage from "constructure" , i donn't know else that i can pass the values for the class by it , but when i must write the programming inside the constructure & y ? thanks.
in short : constructer are the first method that will be called when an object of that class is initialized. so its a good idea to put all variable initialization over there. get more details from www.java.sun.com
Joined: Dec 12, 2003
yep, thanks Manoj.. it was usefull link , by constructur details and some other information.. but whould you give an exampple about i put the programing "not the init" in that method "Constructur" ! coz all the programs which i saw them were include the init only ! thanks.
Servlet and Applet classes might contain init methods which are automatically invoked by the container in which they run. This method is a good place to put code that needs to be run on the creation and initialization of an Applet or a Servlet. Since a constructor is going to be used to create an instance of the Servlet or Applet as appropriate, it would also work to place code that needs to be run at the creation of the Servlet or Applet in that code block. Note that in Java a constructor is not a method. A method is a member of something - it's a member of a class in the case of static methods, or a member of an object in the case of instance methods. Constructors aren't members of anything. Methods return values - sometimes void. Constructors cannot return anything. Methods can be inherited. Constructors are never inherited. Some other languages do use the term constructor method when referring to what must be a similar construct as a constructor in Java, but in Java they're just called constructors.