Java LinkedList公共對象pollLast()方法(帶示例)

LinkedList公共對象pollLast()方法 (LinkedList public Object pollLast() method)

  • This method is available in package java.util.LinkedList.pollLast().

    軟件包java.util.LinkedList.pollLast()中提供了此方法。

  • This method is used to retrieves the last or ending element of the linked list and removes the last element from the list finally.

    此方法用于檢索鏈表的最后一個元素或結尾元素,最后從列表中刪除最后一個元素。

  • If the list is empty then it will return null.

    如果列表為空,則它將返回null。

Syntax:

句法:

    public Object pollLast(){
}

Parameter(s):

參數:

In this method, we don’t pass any object as a parameter in the method but it returns the last object from the linked list and then remove the last element from the list.

在此方法中,我們不會在該方法中傳遞任何對象作為參數,但它會從鏈接列表中返回最后一個對象,然后從列表中刪除最后一個元素。

Return value:

返回值:

The return type of this method is not void that means this method returns last object or element (i.e. It returns only last element in the list). If the list is empty then it will not give any exception.

該方法的返回類型不是void,這意味著該方法返回最后一個對象或元素(即,它僅返回列表中的最后一個元素)。 如果列表為空,則不會給出任何異常。

Java程序演示LinkedList pollLast()方法的示例 (Java program to demonstrate example of LinkedList pollLast() method)

import java.util.LinkedList;
public class LinkList {
public static void main(String[] args) {
LinkedList list = new LinkedList();
// use add() method to add elements in the list 
list.add(10);
list.add(20);
list.add(30);
list.add(40);
list.add(50);
//  Current list Output
System.out.println("The Current list is:" + list);
//  Using pollLast() method it will retrieve last element 
// with removing the last element from the list  
System.out.println("The Last Element In The List is:" + list.pollLast());
//  Updated list Output after implementing pollLast()
System.out.println("The Updated List after implementing pollLast() The list is:" + list);
}
}

Output

輸出量

D:\Programs>javac LinkList.java
D:\Programs>java LinkList
The Current list is:[10, 20, 30, 40, 50]
The Last Element In The List is:50
The Updated List after implementing pollLast() The list is:[10, 20, 30, 40]

翻譯自: https://www.includehelp.com/java/linkedlist-public-object-polllast-method-with-example.aspx

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

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

相關文章

python編寫學生成績排序_Python實現按學生年齡排序的實際問題詳解

前言 本文主要給大家了關于利用Python按學生年齡排序的相關內容,分享出來供大家參考學習,下面話不多說了,來一起看看詳細的介紹: 問題:定義一個Class:包含姓名name、性別gender、年齡age,需要按…

前方危險-讓很多“高逼格”高管深刻反思的文章

在很多的時候,現實會讓我們每個人迷惑,周邊的人和事可以讓人極度的膨脹,你可以想吃了迷藥一樣,分不清是現實還是虛幻。很久以前,在公司的一次會議上,某主管告訴我們說,“他一個同事,…

oracle實例的概念組成,oracle體系結構的兩個基本概念:數據庫和實例

您可能感興趣的話題:oracle核心提示:要了解oracle體系結構必須先了解兩個基本的概念: 數據庫和實例.要了解oracle體系結構必須先了解兩個基本的概念: 數據庫和實例.一: 數據庫數據庫(database)是一個數據集合.無論數據庫是采用關系結構還是面向對象結構,…

c#二維數據最大最小值_C#| 打印類型,各種數據類型的最大值和最小值

c#二維數據最大最小值In the below example – we are printing types, min value, max value of various data types in C#, like integer data types, floating point data types, Boolean data type, Reference types, Nullable types. 在下面的示例中-我們正在打印C&#x…

自定義taglib引入失敗_小程序拼團總失敗?看看微信官方和開發者們怎么說

閱讀時間:6m最懂小程序生態商業的自媒體可怕... 剛過國慶,南方還在短袖短裙,北方竟然都下雪了!什么叫一天之內感受四季?曉程序觀察(yinghoo-tech)的小伙伴們算是深刻體驗了,穿著短袖上飛機,抵達…

微信公眾平臺開發5:翻譯功能

思路分析首先對用戶發送過來的消息進行判斷,判斷消息里是否含有“翻譯”關鍵字,如果有,則提取翻譯內容,然后調用網絡上開放的翻譯API 進行翻譯。我們用有道翻譯API:http://fanyi.youdao.com/openapi?pathdata-mode記下…

Linux之基礎I/O

目錄 一、C語言中的文件操作 二、系統文件操作I/O 三、文件描述符fd 1、文件描述符的引入 2、對fd的理解 3、文件描述符的分配規則 四、重定向 1、重定向的原理 2、重定向的系統調用dup2 五、Linux下一切皆文件 一、C語言中的文件操作 1、打開和關閉 在C語言的文…

moore和mealy_Mealy機和Moore機的比較研究 目錄

moore和mealyFinite automata may also have outputs corresponding to each input symbol. Such finite automata are known as finite automata with the output. 有限自動機還可以具有與每個輸入符號相對應的輸出。 這種有限自動機稱為輸出的有限自動機。 There are two fi…

oracle sys連接不上,oracle – 為什么我不能在SYS擁有的對象上創建觸發器?

在嘗試創建名為ghazal_current_bef_upd_row的觸發器時&#xff1a;create trigger ghazal_current_bef_upd_rowbefore update on ghazal_currentfor each rowwhen (new.Rating < old.Rating)begininsert into ghazal_current_audit(GhazalName,Old_Rating,New_Rating)values…

大一python編程題_請教python編程問題(作業就剩這幾道題了)

該樓層疑似違規已被系統折疊 隱藏此樓查看此樓1. def cleanword(word):(用Python寫出程序&#xff0c;使程序可以通過下面的doctest)""">>> cleanword(what?)what>>> cleanword("now!")now>>> cleanword(?"word!,$…

Linux筆記1-5 --用戶

## 1 ## 用戶理解用戶就是系統使用者的身份在系統中用戶存儲為若干竄字符若干個系統配置文件用戶信息涉及到的系統配置文件&#xff1a;/etc/passwd ###用戶信息用戶&#xff1a;密碼&#xff1a;uid&#xff1a;gid&#xff1a;說明&#xff1a;家目錄&#xff1a;用戶使用…

python運維開發培訓_運維架構師-Python 自動化運維開發-014

運維架構師-Python 自動化運維開發-014九、標準數據類型1、為什么編程語言中要有類型類型有以下幾個重要角色&#xff1a;對機器而言&#xff0c;類型描述了內存中的電荷是怎么解釋的。對編譯器或者解釋器而言&#xff0c;類型可以協助確保上面那些電荷、字節在程序的運行中始終…

JavaScript | 演示函數中按值調用的示例

Here, we are designing a function named change() that has an argument and we are trying to change the value of the passed argument inside the function, but it will not effect to the main/actual argument that is passed as the argument while calling. 在這里&…

機器視覺支架制作(帶效果測試)

圖像處理系統中&#xff0c;鏡頭、光源的選配&#xff0c;對于最后能否產生穩定的識別效果至關重要。而搭載鏡頭、光源的是支架。機器視覺的支架一般都是根據項目的具體需要進行配置的&#xff0c;搜索淘寶能夠得到一些商品。 這些支架形狀不一&#xff0c;價格在數百元到千元之…

c語言中將整數轉換成字符串_在C語言中將ASCII字符串(char [])轉換為十六進制字符串(char [])...

c語言中將整數轉換成字符串Given an ASCII string (char[]) and we have to convert it into Hexadecimal string (char[]) in C. 給定一個ASCII字符串(char [])&#xff0c;我們必須在C中將其轉換為十六進制字符串(char [])。 Logic: 邏輯&#xff1a; To convert an ASCII …

redis rdb aof區別_理解Redis的持久化機制:RDB和AOF

什么是Redis持久化?Redis作為一個鍵值對內存數據庫(NoSQL)&#xff0c;數據都存儲在內存當中&#xff0c;在處理客戶端請求時&#xff0c;所有操作都在內存當中進行&#xff0c;如下所示&#xff1a;這樣做有什么問題呢&#xff1f;注 意文末有&#xff1a;3625頁互聯網大廠面…

python--批量下載豆瓣圖片

溜達豆瓣的時候&#xff0c;發現一些圖片&#xff0c;懶得一個一個扒&#xff0c;之前寫過c#和python版本的圖片下載&#xff0c;因此拿之前的Python代碼來改了改&#xff0c;折騰出一個豆瓣版本&#xff0c;方便各位使用 # -*- coding:utf8 -*- import urllib2, urllib, socke…

linux touch權限不夠,Linux下的Access、Modify、Change , touch的使用以及權限問題

每個文件在linux下面都會記錄許多的時間參數&#xff0c;其實是有三個主要的變動時間&#xff0c;那么&#xff0c;這三個時間的意義又是什么&#xff1f;下面我們來介紹&#xff1a;* Modify time(mtime)當該文件的“內容數據”更改時&#xff0c;就會更新這個時間。內容數據指…

scala 獲取數組中元素_從Scala中的元素列表中獲取隨機元素

scala 獲取數組中元素We can access a random element from a list in Scala using the random variable. To use the random variable, we need to import the Random class. 我們可以使用隨機變量從Scala中的列表訪問隨機元素。 要使用隨機變量&#xff0c;我們需要導入Rand…

ubuntu14.04下安裝cudnn5.1.3,opencv3.0,編譯caffe及配置matlab和python接口過程記錄

已有條件: ubuntu14.04cuda7.5anaconda2(即python2.7)matlabR2014a 上述已經裝好了,開始搭建caffe環境. 1. 裝cudnn5.1.3,參照:2015.08.17 Ubuntu 14.04cuda 7.5caffe安裝配置 詳情:先下載好cudnn-7.5-linux-x64-v5.1-rc.tgz安裝包(貌似需要官網申請) 解壓: tar -zxvf cudnn-7.…