//Map with Country Key and City values
Map<String, List<String>> objMap = new Map<String, List<String>>();
List<String> usaCityList = new List<String>{'New York', 'Los Angeles', 'Chicago', 'San Diego'};
objMap.put('USA', usaCityList);
List<String> indiaCityList = new List<String>{'New Delhi', 'Mumbai', 'Chennai', 'Bangalore'};
objMap.put('India', indiaCityList);
//Get All cities in a single list variable
List<String> objCityList = new List<String>();
for (List<String> obj : objMap.values()){
objCityList.addAll(obj);
}
System.debug('objCityList-' + objCityList);
Set<String> accountNames = new Set<String>{'%Sam%', '%App%', '%Len%','%Nok%'};
List<Account> accList = [Select Id, Name From Account Where Name LIKE :accountNames];
List Collection in Like:
List<String> accountNameList = new List<String>{'%Sam%', '%App%', '%Len%','%Nok%'};
List<Account> accList = [Select Id, Name From Account Where Name LIKE :accountNameList];
//List of string variable
List<String> objList = new List<String>();
//Set of string variable
Set<String> objSet = new Set<String>();
objList.add('A');
objList.add('B');
objList.add('C');
//Use addAll() to add list of string to Set
objSet.addAll(objList);
//Or Use Set Constructor
Set<String> objSetData = new Set<String>(objList);
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.AcceptReject