aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Multi constructors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Multi constructors" Watch "Multi constructors" New topic
Author

Multi constructors

Hama Kamal
Ranch Hand

Joined: May 29, 2011
Posts: 144

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]




``Worry does not empty tomorrow of its sorrow; it empties today of its strength.''
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10048
    
163

Hama Kamal wrote: i mean does any one of them affect the others???


What exactly do you mean by affecting other constructors?

[My Blog] [JavaRanch Journal]
Hama Kamal
Ranch Hand

Joined: May 29, 2011
Posts: 144

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

Joined: Jul 20, 2005
Posts: 10048
    
163

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

Joined: May 29, 2011
Posts: 144

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
 
subject: Multi constructors