Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ArrayList<Book> books=new ArrayList<Book>();
- ArrayList<Painting> paintings=new ArrayList<Painting>();
- public void addToList(Object myObject)
- {
- if(myObject instanceof Book)
- books.add(myObject);
- else if(myObject instanceof Painting)
- paintings.add(myObject);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement