- class Test
- {
- public static void main(String[] args)
- {
- int[] arr=new int[]{25,45,11,3,2,48,61};
- System.out.println(arrayMethod_2(arr));
- }
- public static String arrayMethod_2(int[] arr)
- {
- int temp=0;
- String str="";
- for(int i=0,length=arr.length;i<length-1;i++)
- {
- for(int j=0;j<length-1-i;j++)
- {
- if(arr[j]<arr[j+1])
- {
- temp=arr[j];
- arr[j]=arr[j+1];
- arr[j+1]=temp;
- }
- }
- str+=arr[length-i-1]+",";
- }
- return str+= arr[0];
- }
- }
复制代码 |