Set集合

Set<String> set1 = new Set<String>();
set1.add('1');
set1.add('2');
Set<String> set2 = set1.clone();
Boolean isEquals = set1.equals(set2);
Boolean isContains = set1.contains('1');
Integer setSize = set1.size();
Iterator<String> Iterator2 = set1.iterator();
while(iterator2.hasNext()){
System.debug('set item:'+ iterator2.next());
}
Boolean isEmpty = set1.isEmpty();
List<String> anotherList = new String[]{'1','3'};
set1.retainAll(anotherList);
Iterator<String> iterator3 = set1.iterator();
while(iterator3.hasNext()){
System.debug('set item via retainAll:'+iterator3.next());
}

结果如下所示

58、salesforce学习笔记(五)-LMLPHP

05-27 01:12