Object lastKey() Returns this set's last key. : Map « Utility Classes « SCJP

Home
SCJP
1.Java Source And Data Type
2.Operators
3.Modifiers
4.Type Casting
5.Statements
6.Object Oriented
7.Thread
8.Utility Classes
9.File
SCJP » Utility Classes » Map 
8.20.14.Object lastKey() Returns this set's last key.
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;

public class MainClass {
  public static void main(String[] argv) {
    Map map = new TreeMap();
    map.put("key""value");
    map.put("key2""value2");
    map.put("key3""value3");

    SortedMap sortedMap = (SortedMapmap;
    System.out.println(sortedMap.lastKey());

  }
}
key3
8.20.Map
8.20.1.Create a Hashtable and stores a Uniform Resource Locator (URL) String with a short String as a key
8.20.2.HashMap extends AbstractMap and is similar to Hashtable.
8.20.3.Maps differ from lists and sets in that they are ordered collections of key-value pairs.
8.20.4.Object put(Object key, Object value) Associates key and value.
8.20.5.Object get(Object key) Returns the value associated with key, or null if no value is associated with key.
8.20.6.boolean containsKey(Object key) Returns true if the Map associates some value with key.
8.20.7.void clear() Empties the Map.
8.20.8.Set keySet() Returns a Set containing the Map's keys.
8.20.9.Collection values() Returns a collection containing the Map's values.
8.20.10.A Hash Map's keys are iterated in unpredictable order.
8.20.11.A Tree Map's keys are iterated in natural order.
8.20.12.TreeMap class implements the java.util.SortedMap interface, which extends java.util.Map.
8.20.13.SortedMap: Object first() Returns this set's first key.
8.20.14.Object lastKey() Returns this set's last key.
8.20.15.SortedMap headMap(Object toKey) Returns a view of the portion of this sorted map whose keys are strictly less than toKey.
8.20.16.SortedMap tailMap(Object fromKey) Returns a view of the portion of this sorted map whose keys are greater than or equal to fromKey.
8.20.17.SortedMap subMap(Object fromKey, Object toKey) Returns a view of the portion of this sorted map whose keys range from fromKey, inclusive, to toKey, exclusive.
8.20.18.Maps check for key uniqueness
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.