案例:数组{12,34,4567,22} 转换后1222344567
解题思路:对数组进行排序,后将数组转换为字符串
package com.demo; /** * * {12,34,4567,22} * 1222344567 * @author Administrator * */ public class ArraySort { public static void main(String[] args) { int[] a={12,34,4567,22}; System.out.println("变化前的数组:"); for (int i = 0; i < a.length; i++) { System.out.print(a[i]+" "); } System.out.println(); SortedArr(a); String s=""; for (int i = 0; i < a.length; i++) { s+=a[i]; } System.out.println("变化后的数组:"); System.out.println(s); } public static void SortedArr(int[] a){ int temp; for (int i = 0; i < a.length; i++) { for (int j = i+1; j < a.length; j++) { if(a[i]>a[j]){ temp=a[i]; a[i]=a[j]; a[j]=temp; } } } } }