• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

need advice on Element and Node

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi..
is there anything wrong with this code?



im confuse here
--> is a Element
but i the function can receive in as an element, i need receive as an node type.

can i declare

I know element is the subinterface of node but i dont get get what is the diff when i declare "Element root" instated of "Node root"

Hope someone able to advice me on this.

thanks in advance.
 
Sheriff
Posts: 27456
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's just basic polymorphism. An Element "IS A" Node, because Element is a subinterface of Node. That means that Element has all the methods that Node does. It also means that Element could have some other methods that Node doesn't have, and in fact it does. It has methods allowing you to access the attributes of the element. Those methods aren't in the Node interface because not all types of nodes have attributes.
 
Norazanita Adnan
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks..so meaning now it find i declare as Element and send as and Node type..thanks..no i start to like programming....
 
I have a knack for fixing things like this ... um ... sorry ... here is a consilitory tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic