java 方法 示例_Java ArrayDeque pollFirst()方法與示例

java 方法 示例

ArrayDeque類pollFirst()方法 (ArrayDeque Class pollFirst() method)

  • pollFirst() Method is available in java.lang package.

    pollFirst()方法在java.lang包中可用。

  • pollFirst() Method is used to return the first element of the queue denoted by this deque but with removing the first element from this deque.

    pollFirst()方法用于返回此雙端隊列表示的隊列的第一個元素,但會從此雙端隊列中刪除第一個元素。

  • pollFirst() Method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    pollFirst()方法是一種非靜態方法,只能通過類對象訪問,如果嘗試使用類名稱訪問該方法,則會收到錯誤消息。

  • pollFirst() Method does not throw an exception at the time retrieving element of this deque.

    pollFirst()方法在獲取此雙端隊列的元素時不會引發異常。

Syntax:

句法:

    public T pollFirst();

Parameter(s):

參數:

  • It does not accept any parameter.

    它不接受任何參數。

Return value:

返回值:

The return type of the method is T, it returns the first element denoted by this deque otherwise it returns null, when this deque is "blank".

方法的返回類型為T ,它返回此雙端隊列表示的第一個元素,否則當此雙端隊列為“空白”時返回null。

Example:

例:

// Java program to demonstrate the example 
// of T pollFirst() method of ArrayDeque 
import java.util.*;
public class PollFirstOfArrayDeque {
public static void main(String[] args) {
// Creating an ArrayDeque with initial capacity of
// storing elements
Deque < String > d_queue = new ArrayDeque < String > (10);
// By using add() method to add elements
// in ArrayDeque
d_queue.add("C");
d_queue.add("C++");
d_queue.add("Java");
d_queue.add("Php");
d_queue.add("DotNet");
// Display Deque Elements
System.out.println("d_queue before pollFirst(): ");
System.out.println("ArrayDeque Elements = " + d_queue);
System.out.println();
// By using pollFirst() method to remove and return the
// element at the first position in ArrayDeque
String ele = d_queue.pollFirst();
// Display Returned Elements
System.out.println("d_queue.pollFirst() : " + ele);
System.out.println();
// Display Deque Elements
System.out.println("d_queue after pollFirst(): ");
System.out.println("ArrayDeque Elements = " + d_queue);
}
}

Output

輸出量

d_queue before pollFirst(): 
ArrayDeque Elements = [C, C++, Java, Php, DotNet]d_queue.pollFirst() : Cd_queue after pollFirst(): 
ArrayDeque Elements = [C++, Java, Php, DotNet]

翻譯自: https://www.includehelp.com/java/arraydeque-pollfirst-method-with-example.aspx

java 方法 示例

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/378841.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/378841.shtml
英文地址,請注明出處:http://en.pswp.cn/news/378841.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

P2P技術詳解(四):P2P技術之STUN、TURN、ICE詳解

目錄1、內容概述2、STUN詳解2.1 RFC3489/STUN2.1.1 報文結構2.1.2實現原理2.1.3STUN功能舉例2.2 RFC5389/STUN2.2.1STUN用途2.2.2報文結構2.3 RFC5389與RFC3489的區別2.4 新特性介紹2.4.1指紋機制2.4.2通過DNS發現服務器機制2.4.3認證和消息完整性機制2.4.4備份服務器機制2.5 R…

比較兩張大小相同的照片的差異,返回數值

比較兩張大小相同的照片的差異&#xff0c;返回數值 from PIL import Image import math import operator from functools import reducedef image_contrast(img1, img2):image1 Image.open(img1)image2 Image.open(img2)h1 image1.histogram()h2 image2.histogram()resul…

poj2115C Looooops

http://poj.org/problem?id2115 參考人家的 如下 如i65534&#xff0c;當i3時&#xff0c;i1 其實就是 i(655343)%(2^16)1 有了這些思想&#xff0c;設對于某組數據要循環x次結束&#xff0c;那么本題就很容易得到方程&#xff1a; x[(B-A2^k)%2^k] /C 即 Cx(B-A)(mod 2^k) 此…

ASP.NET調用javascript腳本的常見方法小結

http://www.codesky.net/article/doc/201004/2010041706872.htm轉載于:https://www.cnblogs.com/ZC_Mo-Blog/archive/2010/11/23/1885125.html

python wait方法_Python條件類| 帶有示例的wait()方法

python wait方法Python Condition.wait()方法 (Python Condition.wait() Method) wait() is an inbuilt method of the Condition class of the threading module in Python. wait()是Python中線程模塊的Condition類的內置方法。 Condition class implements condition variab…

return編程python_python3 第二十一章 - 函數式編程之return函數和閉包

我們來實現一個可變參數的求和。通常情況下&#xff0c;求和的函數是這樣定義的&#xff1a;def calc_sum(*args):ax0for n inargs:ax ax nreturn ax但是&#xff0c;如果不需要立刻求和&#xff0c;而是在后面的代碼中&#xff0c;根據需要再計算怎么辦&#xff1f;可以不返回…

黑色背景下,計算照片白色的區域面積和周長

黑色背景下&#xff0c;計算照片白色的區域面積和周長 import cv2 img cv2.imread(E:\Python-workspace\OpenCV\OpenCV/beyond.png,1)#第一個參數為選擇照片的路徑&#xff0c;注意照片路徑最后一個為正斜杠其他都為反斜杠&#xff1b;第二個參數&#xff0c;其中1表示所選照…

php連接mssql數據庫的幾種方式

數據庫查詢不外乎4個步驟&#xff0c;1、建立連接。2、輸入查詢代碼。3、建立查詢并取出數據。4、關閉連接。 php連接mssql數據庫有幾個注意事項&#xff0c;尤其mssql的多個版本、32位、64位都有區別。 首先&#xff0c;php.ini文件中;extensionphp_pdo_mssql.dll ;extensionp…

通俗易懂:快速理解P2P技術中的NAT穿透原理

目錄1、基礎知識1.1、什么是NAT&#xff1f;1.2、為什么會有NAT&#xff1f;1.3、NAT有什么優缺點&#xff1f;2、NAT的實現方式2.1、靜態NAT2.2、NAPT3、NAT的主要類型3.1、完全錐型NAT&#xff08;Full Cone NAT&#xff0c;后面簡稱FC&#xff09;3.2、受限錐型NAT&#xff…

duration java_Java Duration類| toNanos()方法與示例

duration javaDuration Class toNanos()方法 (Duration Class toNanos() method) toNanos() method is available in java.time package. toNanos()方法在java.time包中可用。 toNanos() method is used to convert this Duration into the number of nanoseconds. toNanos()方…

java 負載均衡_java負載均衡 - 歲月靜好I的個人空間 - OSCHINA - 中文開源技術交流社區...

作用對系統的高可用&#xff0c;網絡壓力的緩解&#xff0c;處理能力擴容的重要手段之一。服務器負載我們通常所說的負載是指&#xff1a;服務器負載軟硬件負載服務器負載又分為&#xff1a;軟件負載--硬件負載軟件負載&#xff1a;通過在服務器上安裝一些具有負載功能或模塊的…

b tree和b+tree_B TREE實施

b tree和btreeB TREE及其操作簡介 (Introduction to B TREE and its operations) A B tree is designed to store sorted data and allows search, insertion and deletion operation to be performed in logarithmic time. As In multiway search tree, there are so many nod…

黑色背景下,將照片內封閉空心圖案的空心區域染成Cyan并保存

在黑色背景下&#xff0c;將照片內封閉空心圖案的空心區域染色 import cv2 import numpy as np img cv2.imread(E:\Python-workspace\OpenCV\OpenCV/beyond.png,1)#第一個參數為選擇照片的路徑&#xff0c;注意照片路徑最后一個為正斜杠其他都為反斜杠&#xff1b;第二個參數…

Ubuntu輸入su提示認證失敗的解決方法

Ubuntu輸入su提示認證失敗的解決方法 啟動ubuntu服務時竟然提示權限不夠&#xff0c;用su切換&#xff0c;輸入密碼提示認證失敗&#xff0c;這下搞了吧&#xff0c;后來一經查閱原來Ubuntu安裝后&#xff0c;root用戶默認是被鎖定了的&#xff0c;不允許登錄&#xff0c;也不允…

SDP協議基本分析(RTSP、WebRTC使用)

目錄一、介紹二、標準 SDP 規范1. SDP 的格式2. SDP 的結構&#xff08;1&#xff09;會話描述&#xff08;2&#xff09;媒體描述三、WebRTC 中的 SDP一、介紹 SDP&#xff08;Session Description Protocal&#xff09;以文本描述各端&#xff08;PC 端、Mac 端、Android 端…

MFC六大關鍵技術(第四部分)——永久保存(串行化)

MFC 六大關鍵技術 ( 第四部分 ) ——永久保存&#xff08;串行化&#xff09; 先用一句話來說明永久保存的重要&#xff1a;弄懂它以后&#xff0c;你就越來越像個程序員了&#xff01; 如果我們的程序不需要永久保存&#xff0c;那幾乎可以肯定是一個小玩兒。那怕我們的記事本…

在網絡中配置思科交換機

By default, all ports of a switch are enabled. As we are talking about layer 2 switching, there is no need to configure IP address or any routing protocol on the switch. In such a situation, the configuration is not focused on the switch. 缺省情況下&#…

黑色背景下,描繪照片的輪廓形狀并保存

描繪照片的輪廓形狀并保存 import cv2 from matplotlib import pyplot as plt # 1.先找到輪廓 img cv2.imread(E:\Python-workspace\OpenCV\OpenCV/beyond.png, 0) _, thresh cv2.threshold(img, 0, 255, cv2.THRESH_BINARY cv2.THRESH_OTSU) image, conturs, hierarchy c…

java pdf合并_Java 合并、拆分PDF文檔

本文將介紹如何在Java程序中合并及拆分PDF文檔&#xff0c;合并文檔時&#xff0c;包括合并多個不同PDF文檔為一個文檔&#xff0c;以及合并PDF文檔的不同頁面為一頁&#xff1b;拆分文檔是&#xff0c;包括將PDF文檔按每一頁拆分&#xff0c;以及按指定頁數范圍來拆分。下面將…

HDU4405 期望

對于期望&#xff0c;首先&#xff0c;對于這個公式中p表示概率&#xff0c;x表示隨機變量 展開則為 ex p1*x1p2*x2p3*x3....... 對于本題 假設 ex[ i ]表示當前 i 走到 n 的期望值。所以若 i 處沒有飛機&#xff0c;ex[ i ]sigma(1/6*ex[ik])1 其中(k1...6) &#xff08;1表示…