title: how can implementing a heap that each node is a class?
body: <p>I want to crate a Heap structure that each node have 2 data , 1) string 2) int
  so i think that each node must be a Class that's name is "heapNode" , but i have a trouble in swap method ,
  please help me </p>
  
  <pre><code>import java.util.ArrayList;
  public class MainHeap {
      ArrayList&lt;heapNode&gt; heap;
  
      MainHeap (){
           new ArrayList&lt;heapNode&gt;();
      }
  
      public int getMin(){
          return heap.get(0).data ;
      }
  
       private int parent(int pos) {
              return  pos / 2;
      }
  
       private void swap(int pos1, int pos2) {
              heapNode temp =new heapNode();
  
              temp = heap.get(pos1);
              heap.get(pos1) = heap.get(pos2);
              heap.get(pos2) = temp;
              }
       public void insert(int elem) {
  
              int max = heap.size();
              heap.get(max).data = elem ;
              int current = heap.size() ;
              while (heap.get(current).data &lt; heap.get(parent(current)).data){
                  swap ( current , parent(current));
              }
  
          }
  
  }
  </code></pre>
  
  <p>and this is my heapNode class</p>
  
  <pre><code>public class heapNode {
      int data;
      String fileName;
  }
  </code></pre>
  
  <p>the swap method has error but i cant solve errors </p>