static void swap(int[] array, int index1,int index2){ int t = array[index1]; array[index1] = array[index2]; array[index2] = t; }