title: is correct translated code C# to Java?
body: <p>Ok i Edited post to short version i want to ask about methods in c#: TryGetValue and sorting list by the compare (IComparator).</p>
  
  <p>I need write this methods in Java so I wrote this code. Asking to developers which know both this language is that correct??</p>
  
  <p>1) First question- TryGetValue is that methods wrote in Java make the same?
  c#:</p>
  
  <pre><code>     Node value;
      if (!nodes.TryGetValue(nodeId,out value)) return false;
  </code></pre>
  
  <p>to Java:</p>
  
  <pre><code>Node value;
      if (!nodes.containsKey(nodeId)){
        return false;
      }else{
        value = nodes.get(nodeId);
      }
  </code></pre>
  
  <p>2)And Sorting by the comparator in java work the same?</p>
  
  <pre><code>      static int compareNodes(Node n1, Node n2)
          {
              if (n1.f &gt; n2.f) return 1;
              if (n1.f &lt; n2.f) return -1;
              return 0;
          }
  
              list.Sort(compareNodes);
  </code></pre>
  
  <p>And this in Java:</p>
  
  <pre><code> @Override
          public int compare(Node nodeFirst, Node nodeSecond) {
              if (nodeFirst.f &gt; nodeSecond.f)
                return 1;
              if (nodeFirst.f &lt; nodeSecond.f)
                return -1;
              return 0;
          }
  
              Collections.sort(nodeList, new OpenList());
  </code></pre>