「java」java.util.ArrayDeque.pollLast()の使い方

javaコード
package excers;

import java.util.ArrayDeque;
import java.util.Deque;

public class PollLastDemo {

public static void main(String[] args) {
// create an empty array deque with an initial capacity
Deque<Integer> eq = new ArrayDeque<Integer>(8);

// use add() method to add elements in the deque
eq.add(31);
eq.add(43);
eq.add(56);
eq.add(12);

// printing all the elements available in deque
for (Integer number : eq) {
System.out.println(“Value = " + number);
}
int tt = eq.pollLast();
System.out.println(“Element removed is " + tt);

// printing all the elements available in deque after using pollLast()
for (Integer number : eq) {
System.out.println(“Value = " + number);
}
}

}

実行結果
Value = 31
Value = 43
Value = 56
Value = 12
Element removed is 12
Value = 31
Value = 43
Value = 56

Java

Posted by arkgame