java排序题

题目:

java排序题_第1张图片

 代码:

package daysreplace;
import com.sun.jdi.IntegerValue;
import java.util.Arrays;
public class Test {
    public static void main(String[] args) {
        String str = "11,22,33,55,8,7";
        String[] strArr = str.split(",");
        int[] ints = new int[strArr.length];
        for (int i = 0; i < strArr.length; i++) {
            ints[i] = Integer.parseInt(strArr[i]);
        }
        Arrays.sort(ints);
        for (int i = 0; i < ints.length; i++) {
            System.out.print(ints[i]);
            if(i!=ints.length-1){
                System.out.print(",");
            }
        }
    }
}

 

java排序题_第2张图片

你可能感兴趣的:(java基础,java,开发语言)