title: hashmap in java android, returning null values and repeating keys
body: <p>I am using the following code when getting data from firebase to convert it into a hashmap:</p>
  <p>code calling method in fragment:</p>
  <pre><code>@Override
      public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
          super.onViewCreated(view, savedInstanceState);
          Log.d(&quot;LOG&quot;, &quot;onViewCreated: &quot; + biViewModel.getBiFactorList(biViewModel.getBiSnapShotList(), biViewModel.getBiBehavior(), biViewModel.getBiInspection()));
      }
  </code></pre>
  <p>method itself in viewmodel:</p>
  <pre><code> public Map&lt;String, Integer&gt; getBiFactorList(List&lt;DocumentSnapshot&gt; snapshotList, String behavior, String biInspection) {
          Map&lt;String, Integer&gt; factorMap = new HashMap&lt;&gt;();
          for (DocumentSnapshot snapshot : snapshotList) {
  //check if snapshot matches user option and contains the field
              if (snapshot.getString(&quot;behavior&quot;).equals(behavior) &amp;&amp; snapshot.contains(biInspection)) {
  
                  String tempString = snapshot.getString(biInspection);
                  Integer tempInt = factorMap.get(tempString);
  //add k/v to hashmap
                  factorMap.put(tempString.trim().toLowerCase(), (tempInt== null) ? 1 : tempInt + 1);
  
              }
          }
          return factorMap;
      }
  </code></pre>
  <p>result log:</p>
  <p><code>D/LOG: onViewCreated: {item,items,anentry=1, thougt,thought=1, thought=2, though=1}</code></p>
  <p>As you can see, thought=1, thought=2 should be 1 key with a value of 3, and several keys do not even have values</p>
  <p>I have tried using different collections (somehow hashtable even returns null value), I don't understand why I am getting duplicate keys and null values when I should not be doing so when calling put</p>