• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

inheriting a class

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Will someone please give me a hint on how I can get my parent class to inherit another class, for example, the chart data structure?
 
Bartender
Posts: 1844
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Of course, if you want to use an interface, use "implements" in the class declaration. A class can extend at most one other class (and, in fact, has to...if you don't declare a super class, you by default get the "Object" class as your super class. The Object class is the only class that does not have a super class.) However, it can implement any number of interfaces:

Of course, don't confuse the "is-a" with the "has-a" relationship. A HomoSapiens is a Chordata (going back enough super classes); but it has a Spine (making it a member of the Vertebrata sub-phylum, but that's a bit too involved for this example... )
I hope that this answers your question and does not confuse you further...
 
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Go to http://mindview.net/Books and download the excelent free book "Thinking In Java". Then get the example code as well. Bruce Eckel wrote a very good chapter on inheiritence and Object Oriented Design. Work through the first 3 or 4 chapters of that book and you'll understand it perfectly.
Hope it helps.
Greg
 
I am displeased. You are no longer allowed to read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic