我试图用下面的代码创建一个TreeSet实例。为什么last()和first()方法在java中的Set Interface中不存在
Set<Integer> treeSet = new TreeSet<>();
treeSet.last() //gives compilation error
//solution here is either to cast the treeSet instance
//Or create treeSet using TreeSet concrete class. Which is not a best practice.
这里要做什么?提前致谢。
将这个解决问题了吗? https://stackoverflow.com/questions/9322405/converting-a-treeset-to-arraylist –