PriorityQueue类clear()方法 (PriorityQueue Class clear() method)

  • clear() method is available in java.util package.

    clear()方法在java.util包中可用。

  • clear() method is used to remove all the objects from this PriorityQueue.

    clear()方法用于从此PriorityQueue中删除所有对象。

  • clear() 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.

    clear()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。

  • clear() method does not throw an exception at the time of clearing objects from the queue.

    从队列中清除对象时, clear()方法不会引发异常。

Syntax:

句法:

    public void clear();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of the method is void, it returns nothing.

该方法的返回类型为void ,不返回任何内容。

Example:

例:

// Java program to demonstrate the example
// of void clear() method of
// PriorityQueue
import java.util.*;
public class ClearOfPriorityQueue {public static void main(String args[]) {// Instantiate PriorityQueue
PriorityQueue < String > pq = new PriorityQueue < String > ();
// By using add() method is add
// the given element into priority
// queue
pq.add("C");
pq.add("C++");
pq.add("JAVA");
pq.add("PHP");
pq.add("ANDROID");
// Display PriorityQueue
System.out.println("PriorityQueue: " + pq);
// By using clear() method is to
// remove all the existing elements
// from this PriorityQueue
pq.clear();
// Display Updated PriorityQueue
System.out.println("pq.clear(): " + pq);
}
}

Output

输出量

PriorityQueue: [ANDROID, C, JAVA, PHP, C++]
pq.clear(): []

翻译自: https://www.includehelp.com/java/priorityqueue-clear-method-with-example.aspx

Java PriorityQueue clear()方法与示例相关推荐

  1. Java IOUtils.copy方法代码示例(亲测)

    本文整理汇总了Java中org.apache.commons.io.IOUtils.copy方法的典型用法代码示例.如果您正苦于以下问题:Java IOUtils.copy方法的具体用法?Java I ...

  2. java user directory,Java ProcessBuilder directory()方法与示例

    语法:public File directory (); public ProcessBuilder directory (File dir); ProcessBuilder类directory()方 ...

  3. Java序列化魔术方法及其示例使用

    在上一篇文章中, 您需要了解有关Java序列化的所有知识 ,我们讨论了如何通过实现Java序列化来启用类的可序列化性. Serializable接口. 如果我们的类未实现Serializable接口, ...

  4. catalog java,Java Connection getCatalog()方法与示例

    通常,目录是一个目录,其中包含有关数据集,文件或数据库的信息.而数据库目录中包含所有数据库,基本表,视图(虚拟表),同义词,值范围,索引,用户和用户组的列表. Connection接口的getCata ...

  5. filepermission java,Java FilePermission getActions()方法与示例

    FilePermission类getActions()方法getActions()方法在java.io包中可用. getActions()方法用于检查此FilePermission和给定对象在路径名和 ...

  6. java方法参数Bundle,Java ResourceBundle keySet()方法及示例

    ResourceBundle类keySet()方法keySet()方法在java.util包中可用. keySet()方法用于从此ResourceBundle及其超级捆绑包中获取所有现有键,以在Set ...

  7. java exec waitfor,Java Process waitFor()方法与示例

    流程类waitFor()方法在java.lang包中提供了waitFor()方法. waitFor()方法用于使当前正在运行的线程在需要时等待,直到由该Process对象表示的进程完成其终止为止. 当 ...

  8. java arraylist.add(),Java ArrayList add()方法与示例

    ArrayList类add()方法 语法:public boolean add(T ele); public void add(int indices, T ele);add()方法在java.uti ...

  9. java rollback用法,Java Connection rollBack()方法与示例

    回滚操作将撤消当前事务所做的所有更改,即,如果调用Connection接口的rollBack()方法,则所有修改都将还原到最后一次提交. 您还可以通过将所需的Savepoint对象作为参数传递给此方法 ...

最新文章

  1. linux如何查看指定目录下文件内容,Linux 系统下通过关键词查找指定目录下的文件内容...
  2. 【BZOJ】1572: [Usaco2009 Open]工作安排Job
  3. 基于迭代次数和分类准确率的两种排序
  4. Nginx正向代理与反向代理
  5. 常用的 Emmet 语法
  6. MyBatisEhcache二级缓存的开启
  7. 2021廊坊高考口试成绩查询,2021河北八省联考成绩查询入口
  8. Android—多版本主要适配内容
  9. 干货|MIT线性代数课程精细笔记5
  10. recv函数返回0_函数VLOOKUP与LOOKUP的PK,大战一触即发 Excel神技能!
  11. 【Elasticsearch】Elasticsearch底层系列之Shard Allocation机制
  12. python创建员工_python作业员工信息表程序(第四周)
  13. mysql jsp省市区三级联动_用jsp实现省市区三级联动下拉
  14. ubuntu在终端会话和图形界面之间切换的快捷键
  15. 清除html宏病毒,手动清除EXCEL宏病毒的方法
  16. 常见视频文件格式详解
  17. gst-inspect-1.0 命令详解
  18. Class的基本语法
  19. SpringBoot使用爬虫(初级阶段)
  20. [阅读笔记]蘑菇书《Easy RL》

热门文章

  1. java sqlserver ssl_拦截SQLSERVER的SSL加密通道替换传输过程中的用户名密码实现运维审计(一)...
  2. 室内主题元素分析图_2020届室内设计专业优秀毕业设计作品展(五)
  3. 谈谈你对php的收获和不足,我的收获与不足
  4. window xp系统安装php环境_Windows Server 2003及XP系统如何安装SQL Server 2000数据库?
  5. HTML5 audio 如何实现播放多个MP3音频
  6. 深入理解this机制系列第三篇——箭头函数
  7. 获取当前鼠标的位置以及组件的位置
  8. 如何在 vue-cli v3.0 中使用 SCSS/SASS
  9. Resource接口
  10. IDEA插件之 CodeGlance