import com.dianping.cat.util.StringUtils; import java.util.Arrays; import java.util.Comparator; public class Test5 { public static void main(String[] args) { int[] input = {3, 32, 321}; System.out.println(joinToMinNumber(input)); } public static String joinToMinNumber(int[] input) { if (input == null || input.length == 0) { return ""; } String[] strArr = new String[input.length]; for (int i = 0; i < input.length; i++) { strArr[i] = String.valueOf(input[i]); } Arrays.sort(strArr, new Comparator() { @Override public int compare(String o1, String o2) { return (o1 + o2).compareTo(o2 + o1); } }); return StringUtils.join(strArr, ""); } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)