• Post Reply Bookmark Topic Watch Topic
  • New Topic

purpose of constructor and where it uses.  RSS feed

 
v mallikarjunarao
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
since i new to java,so could you tell me what is the purpose of constructors and where it uses?

thank you.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Constructors are used to create new objects.
Think of objects as data bags. Typically you would create a new object, and then manipulate the data inside that object.

You might also find this link useful.
 
Muhammad Khojaye
Ranch Hand
Posts: 449
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vvv mallikarjunarao wrote:since i new to java,so could you tell me what is the purpose of constructors and where it uses?

Have a look at Constructors
 
Chris John
Greenhorn
Posts: 7
Java MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Constructors are used to create instances of your classes and at the same time initialize the variables. but it is also possible to call a constructor without any parameters. A class can have many constructors and one constructor can even call another constructor. Read the above link or any decent book on Java and you'll understand the concept clearly.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"vvv mallikarjunarao", please check your private messages for an important administrative matter.
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And have a look at the other threads in this forum; somebody else is asking about constructors.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!