permaculture playing cards
The moose likes Beginning Java and the fly likes constructors & methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "constructors & methods" Watch "constructors & methods" New topic

constructors & methods

Daniel Hyslop

Joined: Dec 08, 2004
Posts: 22
I wonder if someone could help me master the concept of using the constructors and methods within a class . ie when a constuctor should be used and when a method should be used within a class

thankyou for your input in advance
marc weber

Joined: Aug 31, 2004
Posts: 11343

Basically, constructers perform tasks necessary to instantite (create an instance of) an object. In other words, constructors -- which are tecnhically neither methods nor members -- get an object ready to do whatever it's supposed to do.

You may want to read Bruce Eckel's "Initialization and Cleanup" chapter from Thinking in Java...

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
Daniel Hyslop

Joined: Dec 08, 2004
Posts: 22
Thanks Marc that has cleared the cobwebs out of the old stetson !
I agree. Here's the link:
subject: constructors & methods
It's not a secret anymore!