Map List Challenge

  • Map, key : value, string : list

// posts for apex category
List<String> apexPosts = new List<String>{'Demystifying Apex Collections', 'Datatypes and variables in Apex'};
// posts for lightning category
List<String> lightningPosts = new List<String>{'Events in Aura framework', 'Developing reusable components'};

// map to store the categories and post lists
Map<String, List<String>> allPosts = new Map<String, List<String>>();

// insert apex posts
allPosts.put('Apex', apexPosts);
// insert lightning posts
allPosts.put('Lightning', lightningPosts);

//printing all posts along with categories
System.debug(allPosts);

Last updated