I will in this method descending order number integer
package sortarray;
public class start {
public static void main(String[] args) {
int [] numb={10,12,8,6,2};
sortarray(numb);
}
public static void sortarray(int [] input){
int max=input[0];
int [] sortmax=input;//i don't know how this array sortmax initialized first
for (int i=0;i<input.length;i++)
if(max<input[i]){
max=input[i];
sortmax[i]=max;//this array is not work
}
for (int j=0;j<sortmax.length;j++)
System.out.print(" "+sortmax[j]);
}
}
but into this method, (sortmax
) is not work why?