File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Constructor - Which are the difference between methods and constructors? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Constructor - Which are the difference between methods and constructors?" Watch "Constructor - Which are the difference between methods and constructors?" New topic
Author

Constructor - Which are the difference between methods and constructors?

André Asantos
Ranch Hand

Joined: Nov 23, 2009
Posts: 234
Constructor - Which are the difference between methods and constructors? Give me an
exemple please...

André AS


André AS
W. Joe Smith
Ranch Hand

Joined: Feb 10, 2009
Posts: 710
Constructors run any time a class is created and don't have a return type.

I recommend reading this.


SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
André Asantos
Ranch Hand

Joined: Nov 23, 2009
Posts: 234
Thank you very much...
André AS
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36478
    
  16
The name of the constructor is exactly the same as the name of the class. Remember: no return type.
Danish Sualeh
Greenhorn

Joined: Oct 06, 2005
Posts: 11
To add , constructors should really be concerned with initializing a class instance.

Doing too much work in the constructor may cause problems down the line such as when you want to unit test your code , etc.

In such cases , work should be delegated to methods
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Constructor - Which are the difference between methods and constructors?
 
Similar Threads
constructors in java
what is the difference between static variable and static block
Costructor return type?
What does "pass object to constuctor" mean?
Interview Questions