List<String> StringTempList = new List<String>{'One','two','Three','Four','One','two'};
set<String> setTempString = new set<String>();
set<String> duplicateTempString = new set<String>();
for(String s:StringTempList ){
if(!setTempString.add(s)){
duplicateTempString .add(s);
}
}
System.debug('duplicatelistString----'+duplicateTempString );
System.debug('duplicatelistString----'+duplicateTempString.add('ten'));
set<String> setTempString = new set<String>();
set<String> duplicateTempString = new set<String>();
for(String s:StringTempList ){
if(!setTempString.add(s)){
duplicateTempString .add(s);
}
}
System.debug('duplicatelistString----'+duplicateTempString );
System.debug('duplicatelistString----'+duplicateTempString.add('ten'));
No comments:
Post a Comment