Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. ArrayList<Book> books=new ArrayList<Book>();
  2. ArrayList<Painting> paintings=new ArrayList<Painting>();
  3.  
  4. public void addToList(Object myObject)
  5. {
  6. if(myObject instanceof Book)
  7. books.add(myObject);
  8.  
  9. else if(myObject instanceof Painting)
  10. paintings.add(myObject);
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement