Retrieves the set of keys in a TreeMap object.
Package: java.util
Assembly: vjslib (in vjslib.dll)
Return Value:
The set of keys contained in the TreeMap object.
Example:
In this example, you create and initialize a TreeMap object, and then you display the keySet contained in the object.
Package: java.util
Assembly: vjslib (in vjslib.dll)
- public java.util.Set keySet();
public java.util.Set keySet();
Return Value:
The set of keys contained in the TreeMap object.
Example:
In this example, you create and initialize a TreeMap object, and then you display the keySet contained in the object.
- // TreeMap-keyset1.jsl
- // TreeMap.keySet example
- import java.util.*;
- public class MyClass
- {
- public static void main(String[] args)
- {
- // Create a TreeMap object:
- TreeMap tm = new TreeMap();
- // Add some elements:
- tm.put("3","Sally Abolrous");
- tm.put("2","Craig Combel");
- tm.put("5","Pille Mandla");
- // Remove the key set:
- System.out.println("The key set is: " + tm.keySet());
- }
- }
- /*
- Output:
- The key set is: [2, 3, 5]
- */