Write on File

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • javasuniltyata
    New Member
    • Jan 2012
    • 7

    Write on File

    If the ArrayList has a collection of person, friend and relative objects where they have relationships of inheritance. friend is subclass of person and relative is the subclass of friend.
    How do I distinguish any object which is retriving from ArrayList is an instant of that particular class? For example:
    The object that we are retrieving from ArrayList could be object of Person or object of friend or object of relative.
  • Hop3
    New Member
    • Jan 2012
    • 1

    #2
    You can use the instanceof operation:

    if(object instanceof class)
    {
    //Do something
    }

    Comment

    Working...