58、salesforce学习笔记(五)

Set集合

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

结果如下所示

58、salesforce学习笔记(五)_第1张图片

 

你可能感兴趣的:(58、salesforce学习笔记(五))