This is working fine and if i do array.length -1 last index of array is left

public static void main(String[] args) {
// TODO Auto-generated method stub
int [] array = {7,1,22,78,44,9};
for(int i = 0; i<array.length; i++) {
int min = i ;
for(int j=i+1;j<array.length;j++) {
if(array[min]>array[j]) {
min = j;

			 }
			 int temp = array[min];
			 array[min]=array[i];
			 array[i] = temp;
		 }
		 System.out.println(array[i]);
	 }
}

}

@rishabh.chhabra10,
Can you please share the code where you update the change?