This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multi constructors

 
Hama Kamal
Ranch Hand
Posts: 144
Java Linux Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,,

in the example below we have four constructors,, is there any relation between those constructors? i mean does any one of them affect the others???



[Edited by Jaikiran Pai, to wrap the code in a code block]



 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hama Kamal wrote: i mean does any one of them affect the others???


What exactly do you mean by affecting other constructors?
 
Hama Kamal
Ranch Hand
Posts: 144
Java Linux Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jaikiran Pai wrote:
Hama Kamal wrote: i mean does any one of them affect the others???


What exactly do you mean by affecting other constructors?


i mean if we remove any of them with removing it's object in the main class as well,,,,will the program still run?
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hama Kamal wrote:

i mean if we remove any of them with removing it's object in the main class as well


You mean, if you remove one of those constructors and then remove the reference to the constructor from the main() method (which I assume was referencing it), then would the program still compile?

The answer to that is pretty simple - take a look at each of the constructors in that class. Is any of those constructors relying on the other constructor (for example: is there a call from one constructor to the other)? If there isn't any references to the constructor being removed then you can safely remove that constructor. Give it a try, won't take long to test it out

 
Hama Kamal
Ranch Hand
Posts: 144
Java Linux Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jaikiran Pai wrote:
Hama Kamal wrote:

i mean if we remove any of them with removing it's object in the main class as well


You mean, if you remove one of those constructors and then remove the reference to the constructor from the main() method (which I assume was referencing it), then would the program still compile?

The answer to that is pretty simple - take a look at each of the constructors in that class. Is any of those constructors relying on the other constructor (for example: is there a call from one constructor to the other)? If there isn't any references to the constructor being removed then you can safely remove that constructor. Give it a try, won't take long to test it out



you are absolutely right,,,, i just tested and it doesn't ,,,, thanks for your support.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic