TreeMap.keySet Method

阅读更多
Retrieves the set of keys in a TreeMap object.

Package: java.util
Assembly: vjslib (in vjslib.dll)

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]
*/









引自:
http://msdn.microsoft.com/zh-cn/library/aa989061(v=vs.80).aspx













-

你可能感兴趣的:(TreeMap,java,keySet)