问题描述:设有n个正整数,将他们连接成一排,组成一个最大的多位整数
package oj;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class MaxArray{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String[] str;
String s = input.nextLine();
str = s.split(" ");
if (s!=null){
int len = str.length;
Arrays.sort(str, Collections.reverseOrder());
StringBuffer stringBuffer = new StringBuffer("");
for (int i = 0; i < len; i++) {
stringBuffer.append(str[i].toString());
}
BigInteger n = new BigInteger(stringBuffer.toString());
System.out.println(n);
}
}
}
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/df3e393e55acac83ecbee577b0413f67.png)