 <p>Your code will give the ArrayIndexOutOfBoundsException if usrSet is greater than 1. If your intention is to just make a copy of an array, I am not sure why you are doing so many things. Probably the below code may suffice:</p> <p><code> String[] deckCards = new String[setLength]; for(int j = 0; j &lt; cards.length; j++){ temp = cards[j]; deckCards[j]= temp; }</code></p> <p>If you are at liberty to use other api, try exploring java.util.Arrays</p>