title: Why does it keep saying the size of a hashMap is zero after I keep putting things in it?
body: <p>What I am trying to do is add rooms to a hash map (I don't want duplicates) with <code>addRoom()</code>. I am then passing them to the controller with <code>getRoom(String)</code> or <code>getRooms()</code>.</p>
  
  <p>The problem is, as you can see with my multiple System.out.prints, the size keeps staying at <code>0</code>, no matter how many time I run <code>addRoom()</code>. </p>
  
  <p>Am I doing something wrong or is the problem somewhere else in the program?</p>
  
  <pre><code>package calendar;
  
  import java.util.HashMap;
  import java.util.Map;
  
  public class Building {
  
      String buildingName = null;
  
      private Map&lt;String, Classroom&gt; rooms =
          new HashMap&lt;String, Classroom&gt;();
  
      public Building() {
      }
      public Building(String name){
          buildingName=name;
      }
  
      /**
       * @return the rooms
       */
      public Map&lt;String, Classroom&gt; getRooms() {
          System.out.println("room size from building.java:" +
              rooms.size());
          return rooms;
      }
  
      public Classroom getRoom(String roomName) {
          if (rooms.containsKey(roomName)) {
              return rooms.get(roomName);
          }
          return new Classroom("null");
      }
  
      /**
       * @param rooms the rooms to set
       */
      public void setRooms(Map&lt;String, Classroom&gt; rooms) {
          this.rooms = rooms;
      }
  
      public void addRoom(String roomNumber) {
          System.out.println("Room added: "+roomNumber +" to "+ 
              buildingName+ " size:"+rooms.size());
          rooms.put(roomNumber, new Classroom(roomNumber));
      }
  }
  </code></pre>
  
  <p>I call this method from a parser so the code is a bit verbose but I will cut down on it and try to paste just the relevant parts:</p>
  
  <pre><code>private Map&lt;String, Building&gt; currentBuilding = new HashMap&lt;String, Building&gt;();
  </code></pre>
  
  <p>now this is in a for loop that goes over all the blocks of data that need to be parsed:
      currentBuilding.put(building, new Building(building));
      currentBuilding.get(building).addRoom(room);</p>
  
  <p>Where building and room are Strings. The buildings get initiated as they should. And obviously I want the room of each building to be in its corresponding building but this does not seem to happen as intended.</p>