My Phone

作者: 冯文议 | 来源:发表于2018-05-15 17:31 被阅读43次
    Integer[] attr = {1, 8, 5, 6, 0, 7, 9};
    Integer[] telNum = {5, 1, 5, 5, 5, 4, 3, 1, 6, 2, 0};
    StringBuilder phone = new StringBuilder();
    Arrays.sort(attr, (a, b) -> {
        if (a < b) {
            return 1;
        } else if (a > b) {
            return -1;
        }
        return 0;
    });
    for (Integer i : telNum) {
        phone.append(attr[i]);
    }
    System.out.println("My Phone is: " + phone);
    

    相关文章

      网友评论

          本文标题:My Phone

          本文链接:https://www.haomeiwen.com/subject/avjydftx.html