title: Non static comparator inner class
body: <p>I would like to know is it ok to make non static inner class which implements comparator interface.</p>
  
  <p>eg.</p>
  
  <pre><code>public class A {
     private Map&lt;String, Integer&gt; scoreMap;
  
     private final class myComparator implements Comparator&lt;MyOtherClass&gt; {
  
         private int calScore(MyOtherClass ob) {
             int score = ob.someValue * ob.otherValue;
             scoreMap.put(ob.getName(), score);
         }
  
         public int compare(MyOtherClass ob1, MyOtherCLass ob2) {
             return Integer.compare(calScore(ob1), calScore(ob2));
         }   
  
     }
  
  }
  </code></pre>
  
  <p>I would like to use comparator class non static because I want to use non static field "num" and want to modify its value. Is it fine to have non static comparator inner class?</p>
  
  <p><strong>Additional Info</strong></p>
  
  <p>For each object I am calculating score inside compare and sorting accordingly. I need to save those scores in a map which I calculated inside comparator and want to use this map in outer class for further calculation.</p>