It seems to me you don't quite understand how array indices work which is causing the problem here. There's actually two issues that I can see straight off, but only one is causing the exception, one is a more subtle bug.
If you create an array of size n, the valid indices are 0..n-1. So given an array called foo of size 52 (which is what you have here), foo is valid, foo is valid (and everywhere in between) but foo will give you an IndexOutOfBoundsException.
The bad line is here:
int randomNumber = (int) ((52-1+1) * Math.random() + 1);
First off, why is the -1+1 there? You can get rid of that straight away without any difference in the result! Secondly, Math.random() will give a result between 0 and 1 (though it will never be 1, it's an exclusive boundary.) Multiplication takes precedence, so the result is 52*a number between 0 and 1. Let's say the random number was very close to 1 and the result is thus 51.9 (a perfectly valid result.) 1 will be added, giving us 52.9. We then cast to an int (which always just drops the decimal component, it doesn't round) giving us 52, an invalid index. What you actually want here if you're using Math.random() is simply:
int randomNumber = (int) (52 * Math.random());
However, strictly speaking it's better practice to use the Random
class, which performs better when you're just using it for integers.
for(int index = 1; index < cardsArray.length - 1; index++)
This will loop between 1 and 50, thus missing out the first and last elements in the array. This:
for(int index = 0; index < cardsArray.length; index++)
Is probably what you want instead.