字符串内容排序

 

    public static void main(String[] args) {
        LotteryDrawResultVO result = new LotteryDrawResultVO();
        result.setOpencode("2,3,1"); 
        String openCode = Arrays.toString(Arrays.stream(result.getOpencode().split(",")).map(s -> Integer.parseInt(s)).sorted().toArray());
        result.setOpencode(openCode.replaceAll("\\[|\\]|\\s", "")); 
        System.out.println(result);

    }//输出"1,2,3"

 

你可能感兴趣的:(Java)