File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Constructurs advanteges.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Constructurs advanteges.." Watch "Constructurs advanteges.." New topic

Constructurs advanteges..

Anas El-Abboud
Ranch Hand

Joined: Dec 12, 2003
Posts: 31
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 ?

We work in mud to reach sky ..
Manoj Zachariah
Ranch Hand

Joined: Dec 08, 2003
Posts: 65
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
Anas El-Abboud
Ranch Hand

Joined: Dec 12, 2003
Posts: 31
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 !
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
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.

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Anas El-Abboud
Ranch Hand

Joined: Dec 12, 2003
Posts: 31
thanks v. much friend Dirk..
it is really the best board for jave i ever seen..
I agree. Here's the link:
subject: Constructurs advanteges..
It's not a secret anymore!