58、salesforce学习笔记(五)

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()); }

结果如下所示

 

posted @ 2017-02-16 17:12  香港胖仔  阅读(257)  评论(0编辑  收藏  举报