7 lines
533 B
Text
7 lines
533 B
Text
Map<Integer, String> m = new Map<Integer, String>(); // Define a new map
|
|
m.put(1, 'First entry'); // Insert a new key-value pair in the map
|
|
m.put(2, 'Second entry'); // Insert a new key-value pair in the map
|
|
System.assert(m.containsKey(1)); // Assert that the map contains a key
|
|
String value = m.get(2); // Retrieve a value, given a particular key
|
|
System.assertEquals('Second entry', value);
|
|
Set<Integer> s = m.keySet(); // Return a set that contains all of the keys in the map
|