• Post Reply Bookmark Topic Watch Topic
  • New Topic

Method  RSS feed

 
Firman creed
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello =, here below





why in the method toString(),they are call method getM1,M2 and D() why not live call artibut that has definition from start?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37507
552
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They call the get methods in case more logic gets added later. Maybe the getter does some formatting in the future.

It's not a big deal on an internal class either way though.
 
Firman creed
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
means?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37507
552
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose method m1() changes to:



By having toString() call the method instead of the attribute directly, it automatically gets this change.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!