Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.Map.Entry;
import java.util.NavigableMap;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) {

        NavigableMap<String, String> nMap = new TreeMap<>();
        nMap.put("CSS", "style");
        nMap.put("HTML", "mark up");
        nMap.put("Oracle", "database");
        nMap.put("XML", "data");
        System.out.println("Navigable Map:" + nMap);

        Entry<String, String> lowerXML = nMap.lowerEntry("XML");
        Entry<String, String> floorXML = nMap.floorEntry("XML");
        Entry<String, String> higherXML = nMap.higherEntry("XML");
        Entry<String, String> ceilingXML = nMap.ceilingEntry("XML");

        System.out.println("Lower:" + lowerXML);
        System.out.println("Floor:" + floorXML);
        System.out.println("Higher:" + higherXML);
        System.out.println("Ceiling:" + ceilingXML);

        // Get the reverse order view of the map
        NavigableMap<String, String> reverseMap = nMap.descendingMap();
        System.out.println("Navigable Map(Reverse  Order):" + reverseMap);

    }

}