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

Java LinkedList公共对象pollLast()方法(带示例)相关推荐

  1. Java LinkedList公共对象peek()方法(带示例)

    LinkedList公共对象peek()方法 (LinkedList public Object peek() method) This method is available in package ...

  2. java散列法的运用实例,Java HashMap compute() 使用方法及示例

    Java HashMap compute() 使用方法及示例 Java HashMap compute()方法计算一个新值,并将其与哈希映射中的指定键相关联. compute()方法的语法为: has ...

  3. math的用法在java中的使用,Java Math cbrt() 使用方法及示例

    Java Math cbrt() 使用方法及示例 Java Math cbrt()方法返回指定数字的立方根. cbrt()方法的语法为: Math.cbrt(double num) 注意:cbrt() ...

  4. java arraylist 方法返回值,Java ArrayList get() 使用方法及示例

    Java ArrayList get() 使用方法及示例 Java ArrayList get()方法返回指定位置存在的元素. get()方法的语法为: arraylist.get(int index ...

  5. java kryo_Kryo框架使用方法代码示例

    Kryo框架的source已移至https://github.com/EsotericSoftware/kryo ,进入此页面,然后点击右边的Download Zip按钮,就能下载到最新版本的Kryo ...

  6. Java Math toIntExact() 使用方法及示例 long转int

    Java Math toIntExact()方法从指定的long参数返回int值. toIntExact()方法的语法为: Math.toIntExact(long value) 注意:toIntEx ...

  7. java readtimeout_Java HttpURLConnection.getReadTimeout方法代码示例

    import java.net.HttpURLConnection; //导入方法依赖的package包/类 /** * 得到响应对象 * * @param urlConnection * @retu ...

  8. java invalidate_Java Component.invalidate方法代码示例

    import java.awt.Component; //导入方法依赖的package包/类 /** Installs the component we will embed to display t ...

  9. java hasmoreelements_Java IOException.hasMoreElements方法代码示例

    import java.io.IOException; //导入方法依赖的package包/类 /** * fileName���� ���� package �������� ������ ���� ...

最新文章

  1. pythonslice_shift_3. 数据模型
  2. [蓝桥杯2016初赛]卡片换位 bfs+set
  3. linux运行隐藏文件,Linux下如何隐藏文件_网站服务器运行维护,Linux,隐藏文件
  4. python telnet模块 more_[宜配屋]听图阁 - python 处理telnet返回的More,以及get想要的那个参数方法...
  5. spring BeanPostProcessor,BeanFactoryPostProcessor作用
  6. java订单编号生产代码,java 订单编号 生成器,可用于生产环境
  7. mysql常用命令操作
  8. 常用软件包和环境配置(机器学习)
  9. 常用Linux命令 mount df dd
  10. 代写python作业 费用_代写dither method作业、代做python程序设计作业、代写python语言作业、代做Image Dithering作...
  11. 机器学习基础算法28-EM算法
  12. 获取url中带的参数
  13. ElasticSearch + kibana 基础查询文档大全
  14. JAVA实现时间换算
  15. js中(0, function)是什么意思
  16. 三国演义人物关系思维导图模板分享
  17. 修复iPhone系统白苹果问题
  18. Python编程基础——编程环境准备工作
  19. 传图识字有次数限制吗_告诉你一个免费的微信小程序,可以传图识字
  20. MATLAB识别实验,Matlab在图像处理与目标识别方面的应用实验

热门文章

  1. 查询分析300万笔记录_给你100万条数据的一张表,你将如何查询优化?
  2. sqli-lab——Writeup21~38(各种过滤绕过WAF和)
  3. esxi挂载Linux的nfs盘,ESXi安装centos7挂载群晖NFS
  4. UVA - 232 ​​​​​​​Crossword Answers
  5. 捧上天的AI落地困难,“ 不懂变通”的华为云如何应付?
  6. 深度学习在搜索业务中的探索与实践 1
  7. 浅析Nginx 正向代理与反向代理
  8. normalizr API
  9. Myeclipse有关的问题
  10. CSS 字体(font)实例