我試圖用下面的代碼創建一個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 –