Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Sample NavigableMap

import java.util.NavigableMap;
import java.util.TreeMap;

class Main {

    public static void main(String[] args) {
        // Creating NavigableMap using TreeMap
        NavigableMap<String, Integer> numbers = new TreeMap<>();

        // Insert elements to map
        numbers.put("Two", 2);
        numbers.put("One", 1);
        numbers.put("Three", 3);
        System.out.println("NavigableMap: " + numbers);

        // Access the first entry of the map
        System.out.println("First Entry: " + numbers.firstEntry());

        // Access the last entry of the map
        System.out.println("Last Entry: " + numbers.lastEntry());

        // Remove the first entry from the map
        System.out.println("Removed First Entry: " + numbers.pollFirstEntry());

        // Remove the last entry from the map
        System.out.println("Removed Last Entry: " + numbers.pollLastEntry());
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: No Duplicate Key on HashMap 
Java :: first method in jdbc 
Java :: drools spring boot 
Java :: java consonant regex 
Java :: using new to create arrays 
Java :: navigation view item selected 
Java :: Java Using range(e1, e2) Method 
Java :: a multi-value map, Map<K, Collection<V, supporting multiple values per key 
Java :: java change time to hh:mm:ss format 
Java :: how to install java jdk 8 on ubuntu 20.04 for spark 
Java :: {1 2 3 4 5 } 
Java :: java intercambiar la posicion de valores de un array 
Java :: set timeout volley android 
Java :: datapicker java 
Java :: java initialise array in return 
Java :: springboot endpoint body list 
Java :: issue wsdl call java example 
Java :: get material of block bukkit 
Java :: android java sqlite alter table 
Java :: read java reader 
Java :: python to java code conversion 
Java :: Java Insert Elements 
Java :: problem solving using recursion in java 
Java :: Duplicate class com.google.android.gms.internal.firebase_messaging.zzo found in modules jetified-firebase-iid 
Java :: swapping techniques using java 
Java :: java check if instance of subclass 
Java :: java final class 
Java :: can you use java in unity 
Java :: what to do in minecraft 
Java :: Add an instance variable of type Safe to the class Room. This instance variable should be initialised in the constructor of Room, and an appropriate query should be defined to get it. 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =