Bookmark Topic Watch Topic
  • New Topic

constructor chaining  RSS feed

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Report post to moderator
hi ranchers !

im preparing for the OCA Java 8 exam. I have this doubt  in constructor chaining !


in the above code why is chaining actually needed ?
why cant we do something like :
public Mouse(int weight)
{
this.weight=weight;
numTeeth=16;  // since this is anyways a default value
numWhiskers=6; //  since this is anyways a default value
}

what is the use of chaining it !
 
author & internet detective
Marshal
Posts: 37518
554
Eclipse IDE Java VI Editor
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!