Loading, please wait...

A to Z Full Forms and Acronyms

Program to get a portion of a map whose keys are greater than or equal to a given key.

Program to get a portion of a map whose keys are greater than or equal to a given key.
import java.util.*;  
public class demo1 
{  
 public static void main(String args[])
 {  
  TreeMap<Integer,String> treemap=new TreeMap<Integer,String>();      
  treemap.put(1, "C#");
  treemap.put(2, "C++");
  treemap.put(3, "Java");
  treemap.put(4, "Python");
  treemap.put(5, "Perl");
  
  System.out.println("Elements of TreeMap content are: " + treemap);
  System.out.println("Keys which are greater than 3: " + treemap.tailMap(3, false));
  System.out.println("Keys which are equal or greater than 3: " + treemap.tailMap(3));
  }
}
A to Z Full Forms and Acronyms

Related Article