title: error: bad operand types for binary operator '-' while subtracting Integer and int
body: <p>My code is as follows and causing me an error: 
  <code>error: bad operand types for binary operator '-'</code>.
  I am subtracting Integer and int, but I think Java converts that automatically now for us, and it should not cause any error. If I try and print the value of curr.getValue(), I get the correct Integer value. However, when I try and subtract or compare it, I get errors. Do I need to convert Integer to int and then perform operations like '+' and '-'? Shouldn't they be automatically converted from Integer to int and vice-versa? </p>
  
  <pre><code>class Solution {
      private String function(String s){
          HashMap&lt;Character, Integer&gt; map = new HashMap&lt;&gt;();
  
      for(char ch: s.toCharArray()){
          Integer count = map.get(ch);
          if(count == null){
              count = 0;
          }
          map.put(ch, count += 1);
      }
  
      Queue&lt;Map.Entry&lt;Character, Integer&gt;&gt; pq = new PriorityQueue&lt;&gt;(s.length(), (a, b) -&gt; b.getValue() - a.getValue());
  
      pq.addAll(map.entrySet());
  
  
      Queue&lt;Map.Entry&lt;Character, Integer&gt;&gt; q = new LinkedList&lt;&gt;();
      StringBuilder sb = new StringBuilder();
  
      while(!pq.isEmpty()){
          Map.Entry curr = pq.poll();
          sb.append(curr.getKey());
          curr.setValue(   curr.getValue() - 1  ); //this causes an error.
          q.offer(curr);
  
          if(q.size() &lt; 2){
              continue;
          }
  
          Map.Entry e = q.poll();
          if(e.getValue() &gt; 0){
              pq.offer(e);
          }
      }
  
      return sb.toString().length() == s.length() ? sb.toString() : "";   
  }
  
  
  public String reorganizeString(String S) {
      return (function(S));
  
  
  }
  }
  </code></pre>
  
  <p>Please tell me what is causing this error? </p>