标签:print null turn lint form nal system arraylist int
ArrayList<String> list = new ArrayList<String>(); list.add(0, "b"); list.add(1, "a"); list.add(0, "c"); list.add(1, "d");
ITopable<String> sortDesc = ((strList) -> { String tmp = null; for (String item : strList) { if (tmp == null) { tmp = item; continue; } if (item.compareTo(tmp) > 0) { tmp = item; } } return tmp; });
String top = sortDesc.Top(list);
System.out.println(String.format("最大值为:%s", top));
@FunctionalInterface interface ITopable<T> { T Top(List<T> list); }
list.sort((s1, s2) -> { return s1.compareTo(s2); });
list.forEach(s -> {
System.out.println(s);
});
标签:print null turn lint form nal system arraylist int
原文地址:http://www.cnblogs.com/zhshlimi/p/6434382.html