title: Adding member variables of a class to a Map
body: <p>I am having some trouble with this. I want to add the member variables to a map.</p>
  
  <p>Here is my code:</p>
  
  <p>Sprinter.java</p>
  
  <pre><code>public class Sprinter {
      private int age;
      private String name;
      private String address;
  
  public Sprinter() {
  }
  
  public Sprinter(int age, String name, String address) {
      this.age = age;
      this.name = name;
      this.address = address;
  }
  
  public void setAge(int age) {
      return this.age = age;
  }
  
  public int getAge() {
      return this.age;
  }
  
  public void setName(String name) {
      return this.age = age;
  }
  
  public String getName() {
      return this.name;
  }
  
   public void setAddress(String address) {
      return this.address = address;
  }
  
  public String getAddress() {
      return this.address;
  }
  </code></pre>
  
  <p>Worker.java</p>
  
  <pre><code>Sprinter _s = new Sprinter(); 
  _s.setAge(16);
  
  _s.setName("Chris");
  
  _s.setAddress("123 Street");
  </code></pre>
  
  <p>Map.java</p>
  
  <pre><code>public class Maper {
      private Sprinter _sp = new Sprinter();
      private static Map&lt;String, Sprinter&gt; map = new HashMap&lt;String, Sprinter&gt;();
  public void printMap() {
      map.put(_sp.getName(), _sp);
      System.out.println(map);
  </code></pre>
  
  <p>I want the String in the map to be the key, and the values to be the age, address, and name fields from the Sprinter class. In my Worker.java class I use:</p>
  
  <pre><code>Maper _m = new Maper();
  _m.printMap();
  </code></pre>
  
  <p>And my output is: {"Chris", "Chris"};
  However, I want all of the variables to be added. Any advice?</p>