So basically I want to make an algorithm to shuffle my array, all I have is this:
import java.util.*;
class MixUp{
public static void main(String args[]){
int temp, i=0;
boolean flag=true;
int Table[] = new int[5];
Scanner input = new Scanner(System.in);
for(i=0; i<5; i++){
System.out.println("Number? : ");
Table[i] = input.nextInt();
}
for(i=0; i<5; i++){
System.out.printf(Table[i] + "\t");
}
for(i=0; i<5; i++){
temp = Table[i+1];
Table[i+1] = Table[Table.length-i];
Table[Table.length-i] = temp;
if(i+1 == Table.length-i) break;
}
for(i=0; i<5; i++){
System.out.printf(Table[i] + "\t");
}
}
}
And it keeps popping up
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5 at MixUp.main(MixUp.java:17)