title: Overriding toString() / how dot operators truly work
body: <p>I am pretty new to Java, so please tell me if I'm not using some terms correctly.  I have a object class named <code>Player</code> that has a method named <code>getInventory()</code> that returns <code>ArrayList&lt;Item&gt;</code> object named <code>inventory</code>.  </p>
  
  <p>I wanted that method to return the player's inventory in the form of an <code>ArrayList</code> that holds items, and so far, it works fine.  </p>
  
  <p>The <code>Item</code> Class is an abstract base/parent class that my classes <code>Armor</code> and <code>Sword</code> inherit. So, I wanted the formatting (I'm using a purely text-based approach to the "GUI", if you even want to call it that) to look like so:</p>
  
  <ul>
  <li>Banded Mail - Armor</li>
  <li>Chain Mail  - Armor</li>
  <li>Longsword   - Sword</li>
  </ul>
  
  <p>I use the following code to display the "Banded Mail" part (with count being used as it usually is, in a loop):</p>
  
  <pre><code>System.out.print(player.getInventory().get(count).getName());
  </code></pre>
  
  <p>And I tried using the following code to decipher what type of class the object is made from (the name of that class, that is):</p>
  
  <pre><code>System.out.println(player.getInventory().get(count).getClass().toString());
  </code></pre>
  
  <p>I wanted to just print "Armor" or "Sword" or "Shield", based on the Class the Object is made from.  I figured appending <strong>toString()</strong> would do the trick, but it gives me this output instead:</p>
  
  <blockquote>
    <p>class weaponequipdemo.Armor</p>
  </blockquote>
  
  <p>So I would like to know two things:</p>
  
  <ul>
  <li><p>How would I go about overriding <code>toString()</code> to just display the name
  of the class? Where exactly is <code>toString()</code> in the instance of
  <code>player.getInventory().get(count).getClass().toString()</code>? and</p></li>
  <li><p>Most importantly, how is it possible for an object to have so many other methods that can be appended onto it with the dot operator?  I understand for a class like <code>Player</code> to have a method
  named <code>getName()</code>, but what about <code>player.getInventory().get(count)</code>?</p>
  
  <p>Do you put a method inside of a method?  Is that even possible?  From
  the way I've been seeing things, the dot operator is a way of
  depicting going further inside the shell of an object (A method is
  inside of a class), but if that is true, then that means you can have
  methods inside of methods.  I'm confused.</p></li>
  </ul>
  
  <p>I would greatly appreciate your help.</p>