title: Assigning a Variable the Identity of Another
body: <p>I have an Item class. Each Item object is held in an instance of the ItemNode class. ItemNode is an inner class in my CustomList class.</p>
  
  <p>My Item class has an attribute named amount. This refers to how many of that type of Item are owned by the user</p>
  
  <p>My ItemNode class also has an attribute named amount. I want the ItemNode's amount attribute to always equal the amount attribute of the Item object it holds.</p>
  
  <p>In other words, <code>(ItemNode.amount == ItemNode.item.amount)</code>, should always be true, even if I change the value of <code>itemNode.amount</code> later on.</p>
  
  <p>How can I make Java have the same identity for both <code>ItemNode.amount</code> and <code>Item.amount</code>?</p>
  
  <p><strong>My ItemNode Class:</strong></p>
  
  <pre><code>/**
   * Creates nodes to hold Item objects.
   */
  private class ItemNode {
     // the object being held by the node
     private Item item;
     // The type of the object
     private String typeName;
     // How many are owned by the player
     private int amount;
     // What the item-subclass's name is
     private String itemName;
     // the node after this
     private ItemNode next;
  
     ItemNode(Item item) {
  
        this.data = item;
        this.typeName = typeName;
        this.itemName = item.getItemName();
        this.amount = item.getAmount();
        this.next = null;
     }
  }
  </code></pre>