title: Assignment Operator Overloading Java
body: <p>Im having trouble figuring out how to implement the equivalent of overloading the assignment operator in C++ to Java. I know there is no such thing, but I need to simulate it. I've tried overriding the Clone() function, but no luck. Any ideas?</p>
  
  <p>Below is my main</p>
  
  <pre><code> Queue p = new Queue();
   Queue q = new Queue();
  
      p.enqueue('a');
      p.enqueue(9);
      p.enqueue(10);
      p.enqueue(310);
      p.enqueue(8);
  
      q = p;
      System.out.print(p);
  </code></pre>
  
  <p>And here is the clone function</p>
  
  <pre><code>public void Clone(Queue other) throws Throwable
  {
      System.out.println("test\n");
  
      if(this == other)
      {
  
      }
      else
      {            
  while(!isEmpty())
    dequeue();
  
  Node tmp = other.head;
  while(tmp != null){
      this.enqueue((T)tmp.element);
      tmp = tmp.next;
  
  }   
      }
  
  }
  </code></pre>