-
Notifications
You must be signed in to change notification settings - Fork 17
/
Que32.java
43 lines (30 loc) · 906 Bytes
/
Que32.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import java.util.*;
/**
* @author: hyl
* @date: 2019/08/16
**/
public class Que32 {
public String PrintMinNumber(int [] numbers) {
List<Integer> list = new ArrayList<>();
for (int i = 0; i < numbers.length; i++) {
list.add(numbers[i]);
}
Collections.sort(list, new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2) {
String s1 = "" + o1 + o2;
String s2 = "" + o2 + o1;
return s1.compareTo(s2);
}
});
StringBuilder sb = new StringBuilder();
for (Integer integer : list) {
sb.append(integer);
}
System.out.println(sb.toString());
return sb.toString();
}
public static void main(String[] args) {
new Que32().PrintMinNumber(new int[]{1,2,3,4,5});
}
}