title: How to compare a list and string array (Java)?
body: <p>I'm writing an app for Android. I use a string array to pull all player names from shared preferences (has to be a string array). I have a list to pull all active players from shared preferences (has to be a list). I need to check my list to see if it contains any players that are not in my player's array and delete them. I just can't seem to figure out the logic.</p>
  
  <p>For example:</p>
  
  <p>List contains:
  b
  c
  a
  e</p>
  
  <p>Array contains:
  a
  b
  c
  d</p>
  
  <p>Since 'e' exists in List but not in Array, 'e' needs to be removed from the list. I know the commands (.contains(), .remove(), for()), I just can't figure out the logic.</p>
  
  <p>My first attempt was:</p>
  
  <pre><code>for(int x=0;x&lt;numOfPlayers;x++){
          players[x] = getPrefs.getString("player"+Integer.toString(x), " ");
          if(activePlayers.size()&gt;0)
              if(activePlayers.contains(players[x]))
                  playersChecked[x] = true;
          else{
              if(x&lt;activePlayers.size())
                  activePlayers.remove(x);
          }
      }
  </code></pre>
  
  <p>But this removes x from activePlayers if player[x] has an item that activePlayers doesn't, which is fine. It needs to be the other way around.</p>