• 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

Inheritance help

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am learning about inheritance and for the most part I understand all the concepts along with polymorphisms. What I don't understand is how these ideas fall into building a real world application. If someone could, please point me to some code examples that embrace inheritance and polymorphisms. I would like to see how they work in a large application/program. Don't point me to a general Dog extends Animal example, I get the concept. I guess I'm just trying to bridge everything together.

Thanks, Jim
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jim,

Welcome to JavaRanch!

Well, one example is probably right under your nose: Java's Swing and AWT APIs. Everything you can see on the screen is a Component. Some Components are Containers (JPanel, JFrame) because they can contain other Components. Other Components represent "widgets" like JButton, JComboBox, JTree, JList... Every one of these objects is very different from the others, but they all have identical methods to set the size, color, font... all inherited from Component. Obviously each Component has to react differently to be told to resize itself (for example). But to tell a Component to resize itself, you can just call setSize(), not matter what subclass of Component it is.
 
Jim Bain
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ernest,

Thanks for the reply, looking over the awt/sing api has been very helpful!

Jim
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic