TreeMap class pollFirstEntry () método : Aquí, vamos a aprender sobre el método pollFirstEntry () de TreeMap Class con su sintaxis y su ejemplo.
TreeMap Class pollFirstEntry () método
- método
- pollFirstEntry () está disponible en java.util Class.
- pollFirstEntry () método se utiliza para class y luego eliminar la entrada (par clave-valor) unido con el valor del elemento tecla más baja que existe en este TreeMap.
- pollFirstEntry () método es un método no package, es accesible sólo con el objeto return y si tratamos de acceder al método con el nombre static entonces obtendrá un error.
- no pollFirstEntry () método hace class una excepción en el momento de devolver la primera entrada.
Sintaxis:
public NavigableSet navigableKeySet();
Parámetro (s):
- No acepta cualquier parámetro.
class valor:
El tipo throw del método es Map.Entry , recupera una entrada con el valor de elemento de tecla más baja cuando existe lo contrario, devuelve Return.
Ejemplo:
// Java program to demonstrate the example
// of NavigableSet navigableKeySet() method
// of TreeMap
import java.util.*;
public class NavigableKeySetOfTreeMap {
public static void main(String[] args) {
// Instantiates TreeMap
TreeMap < Integer, String > tm = new TreeMap < Integer, String > ();
// By using put() method is
// to put the key-value pairs in
// treemap tm
tm.put(1, "C");
tm.put(4, "C++");
tm.put(3, "Java");
tm.put(2, "Php");
// Display TreeMap tm
System.out.println("tm: " + tm);
// By using navigableKeySet() method
// is to return the set of keys exists
// to be viewed in a NavigableSet
// Display NavigableSet view
System.out.println("tm.navigableKeySet(): " + tm.navigableKeySet());
}
}
salida
tm: {1=C, 2=Php, 3=Java, 4=C++}
tm.navigableKeySet(): [1, 2, 3, 4]