int A = 300; int B = 400; int C = 1000; int D = 500; int []abcd = {A,B,C,D}; Arrays.sort(abcd); // the sequence of array elements will be {300, 400, 500,1000}
just loop it to change the value :
for(int i=0;i