The Artima Developer Community
Sponsored Link

Java Buzz Forum
Why Constructor is Important in Java

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Javin Paul

Posts: 1090
Nickname: javinpaul
Registered: Jan, 2012

Javin Paul is Java Programmer working on Finance domain.
Why Constructor is Important in Java Posted: Sep 12, 2014 9:38 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Javin Paul.
Original Post: Why Constructor is Important in Java
Feed Title: Java67
Feed URL: http://www.java67.com/feeds/posts/default?alt=rss
Feed Description: Java and technology tutorials, tips, questions for all programmers.
Latest Java Buzz Posts
Latest Java Buzz Posts by Javin Paul
Latest Posts From Java67

Advertisement
In simple word, Constructor is a method like block of code which is called by Java runtime during object creation using new() operator. Constructor are special in sense that they have the same name as the Class they are part of. They are also special in a sense that they are called by JVM automatically when you create object. Have you ever thought about Why do you need constructor? What benefits it provide? One reason is to initialize your object with default or initial state, since default values for primitives may not be what you are looking for. One more reason you create constructor is to inform the world about dependencies, a class needs to do it's job. Anyone by looking at your constructors should be able to figure out, what he needs in order to use this class.  For example, following class OrderProcessor needs a Queue and Database to function properly.
Read more »

Read: Why Constructor is Important in Java

Topic: Right way to check if String is empty in Java Previous Topic   Next Topic Topic: Migrate your project from SVN to Git Stash in few steps

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use