• Post Reply Bookmark Topic Watch Topic
  • New Topic

Variables inheritance from abstract classes.  RSS feed

 
Igor Oakgrove
Greenhorn
Posts: 5
VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
People of the ranch!
I have a question for you:
What if i define some variables in


Then i extend it like this


can i use my new Item instance something like this?


or do i have to define mutators for that purpose?
Thanks!
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37462
537
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since it is public, you do not *need* an accessor.

Some notes on best practices:
It is unusual for this to be a static field. (And I don't think you intend for it to be shared across all instances.)
If it is static, you can AbstractItem.number and don't even need an item.
It would be better to make it private and provide mutators.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!