This is the instruction in one of the exercises in our Java class. Before anything else, I would like to say that I \'do my homework\' and I\'m not just being lazy asking someon
Simple way :
int a[]={6,2,5,1}; System.out.println(Arrays.toString(a)); int temp; for(int i=0;i a[j+1]){ // use < for Descending order temp = a[j+1]; a[j+1] = a[j]; a[j]=temp; } } } System.out.println(Arrays.toString(a)); Output: [6, 2, 5, 1] [1, 2, 5, 6]