Q:

Java : Duplication of methods

This feels like such a basic question but this is all new for me:
I have a Person and Room class, both of which have a list of Item objects.
public class Person{
  private ArrayList<Item> items;

  public Person() {
    items = new ArrayList<>();
  }

  public void addItem(){
  ...
  }

  public void removeItem(){
  ...
  }

}    

public class Room {

  private ArrayList<Item> items;

  public Room () {
    items = new ArrayList<>();
  }

  public void addItem(){
  ...
  }

  public void removeItem(){
  ...
  }

}

The item methods e.g. addItem() are duplicated in both the Room class and the Person class which wasn't very nice. I thought about making a separate Inventory class which has a list of items and item methods and then every room and person would have an inventory. 
But then I wouldn't be able to call the Item methods from a Person or Room if I use a private Inventory field.
What's the best way to stop duplication here? Thanks in advance!

A:

You are right.  Making a separate inventory class would be a good OOP design.
I'm glad you didn't say making a parent class to Room and Person since while that would save you the duplication, Rooms and Person's aren't related so they shouldn't really be related in an Object Oriented sense either.
You can use delegation to delegate the add/remove items to your Inventory field.
public class Room {

    private Inventory inventory = new Inventory();

    public void addItem(Item item) {
        inventory.addItem(item);
    }

    public void removeItem(Item item) {
        inventory.removeItem(item);
    }
}

EDIT
Some people are proposing exposing the Inventory and then having a public add/remove methods on that person.getInventory().addItem(item). I think that would violate the Law of Demeter

