• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Constructurs advanteges..

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Anas El-Abboud
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Anas El-Abboud
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks v. much friend Dirk..
it is really the best board for jave i ever seen..
reply
    Bookmark Topic Watch Topic
  • New Topic