thinking in java之Collections工具类的使用
代码摘自《thinking in java》4td
此实例非常好的总结了Collections的一些常见方法的使用。
output:
[one, two, three, four, five, six, one]
'list' disjoint (Four)?: true
max: two
min: five
max w/ comparator: two
min w/ comparator: five
indexOfSubList: -1
lastIndexOfSubList: -1
replaceAll: [Yo, two, three, four, five, six, Yo]
reverse: [Yo, six, five, four, three, two, Yo]
rotate: [three, two, Yo, Yo, six, five, four]
copy: [in, the, matrix, Yo, six, five, four]
swap: [four, the, matrix, Yo, six, five, in]
shuffled: [six, matrix, the, four, Yo, five, in]
fill: [pop, pop, pop, pop, pop, pop, pop]
frequency of 'pop': 7
dups: [snap, snap, snap]
'list' disjoint 'dups'?: true
arrayList: [snap, snap, snap]