Java TreeSet Spliterator() 方法

2024年11月7日 | 阅读 2 分钟

TreeSet 类的 spliterator() 方法用于分割集合的元素并逐个迭代它们。

语法

返回

它返回集合的 spliterator 元素。

示例 1

输出

TreeSet: [4, 6, 9, 12, 18]
Elements of TreeSet after using spliterator() method: 
4
6
9
12
18

示例 2

输出

Elements in TreeSet: 
shristee  vishwakarma  Analyst
shweta    singh        Accountant
suman     chandra      Computer Engineer 
Elements of TreeSet after using spliterator() method: 
shristee  vishwakarma  Analyst
shweta    singh        Accountant
suman     chandra      Computer Engineer