title: How can I swap the element at index0 of an ArrayList with another element if the index of that element is found through a private method? (Java)
body: <p>I'm trying to make a card game where one of the moves a player can take is a swap option, wherein it takes the card in play (the element at index0 of an ArrayList) and swaps it with another. The index of that other card is found through a private method calling a method from a different class that computes for the health*power of that card (and labeled as determiningPower). The card found with the highest determiningPower is swapped with the card at index0.</p>
  
  <p>So far what I wrote has errors because the methods are not of the same type. What can I do for this to work?</p>
  
  <pre><code>public java.lang.String swap()
  {
      if (playerHand.size()&gt;1) //playerHand is the ArrayList&lt;Card&gt; here
      {
          return "-1"; //if the hand only has one card, it cannot swap with anything and must return -1
      }
      else
      {
          Card temp = playerHand.get(0); //card is an object
          playerHand.set(0,playerHand.get(findCard())); //this is where the error is
          playerHand.set(findCard(),temp); //error also here
      }
  }
  </code></pre>
  
  <p>This is the private method findCard() that is referenced in the method swap().</p>
  
  <pre><code>private java.lang.String findCard() //a method of swap that searches for the index number of the element in the array with the highest value
  {
      int largest = 0;
      for (int i=1; i&lt;playerHand.size(); i++)
      {
          if (playerHand.get(i).determiningPower()&gt;playerHand.get(largest).determiningPower())
          {
              largest = i; //determiningPower is a method in a separate class that calculates the health*power. this should find which card has the highest determiningPower
          }
      }
      return java.lang.String.valueOf(largest); 
  }
  </code></pre>
  
  <p>I'm pretty new to this, so any sort of help would be greatly appreciated! </p>