Java ConcurrentSkipListSet last()方法
java.util.concurrent.ConcurrentSkipListSet 的 last() 方法是Java中的一个内置函数,用于返回当前该集合中最后一个(最高)元素。
语法
返回值: 该函数返回当前在这个集合中的最后(最高)元素。
异常: 如果这个集合是空的,该函数会抛出NoSuchElementException。
下面的程序说明了ConcurrentSkipListSet.last()方法。
程序1 :
输出:
程序2: 在last()中显示NoSuchElementException的程序。
输出:
参考资料: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentSkipListSet.html#last-