Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Java pollfirst() and pollLast() Methods

import java.util.TreeSet;
class Main {
    public static void main(String[] args) {
        TreeSet<Integer> numbers = new TreeSet<>();
        numbers.add(2);
        numbers.add(5);
        numbers.add(4);
        numbers.add(6);
        System.out.println("TreeSet: " + numbers);

        // Using pollFirst()
        System.out.println("Removed First Element: " + numbers.pollFirst());

        // Using pollLast()
        System.out.println("Removed Last Element: " + numbers.pollLast());

        System.out.println("New TreeSet: " + numbers);
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: decision tree drools using spring boot 
Java :: java supress unchecked 
Java :: function name in java 
Java :: Java Integer Literals 
Java :: java ordenar numeros ascendente 
Java :: labelled for loop in java 
Java :: reset a jTable without deleting rows 
Java :: jaspersoft masking 
Java :: String in Queue 
Java :: java 11 read file line by line 
Java :: using automapper without dependency injection 
Java :: java tostring methode überschreiben 
Java :: java matrix return a weird string 
Java :: how to convert a jsonobject to a dbobject 
Java :: webview send to console android 
Java :: android loop through string array 
Java :: libgdx load file 
Java :: java makefile clean bin 
Java :: vec add to text field java 
Java :: java schleifendurchläufe zählen 
Java :: java using the segment Information already before the for-loop 
Java :: spring media part max size 
Java :: how to make a ordering system in microsoft visual basic 2010 express console application 
Java :: broswerCallback springboot and jms 
Java :: java spigot string to kyori textcomponent 
Java :: how to get value from property file in spring xml file 
Java :: += operator casting in java 
Java :: Java labeled break Statement 
Java :: search for a string in byte array 
Java :: how to disable the auto-configuration? 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =