Maps

  • Map is a collection of Key value pairs
  • Keys are always unique, Values can be duplicate
//Add/Update
scoreMap.put('Ram', 95);

//Retrive/get
Integer marks = scoreMap.get('Ram');

//Remove with ID
scoreMap.remove('Sam');


//Get All Keys
Set allKeys = scoreMap.keySet();

//Get All Values
List allValues = scoreMap.values();

Share