treeset java

TreeSet类的first()方法 (TreeSet Class first() method)

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

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

  • first() method is used to retrieve the first lowest element in this TreeSet.

    first()方法用于检索此TreeSet中的第一个最低元素。

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

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

  • first() method may throw an exception at the time of returning the first least object in this TreeSet.

    返回此TreeSet中的第一个最小对象时, first()方法可能会引发异常。

    NoSuchElementException – This exception may throw when this TreeSet is “blank”.

    NoSuchElementException-如果此TreeSet为“空白”,则可能引发此异常。

Syntax:

句法:

    public Element first();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of the method is Element, it gets the first least element exists in this TreeSet.

方法的返回类型为Element ,它获取此TreeSet中存在的第一个最小元素。

Example:

例:

// Java program to demonstrate the example
// of Element first() method of TreeSet
import java.util.*;
public class FirstOfTreeSet {public static void main(String[] args) {// Instantiates a TreeSet object
TreeSet < String > tree_set = new TreeSet < String > ();
// By using add() method is to add
// the given object of this TreeSet
tree_set.add("C");
tree_set.add("C++");
tree_set.add("JAVA");
tree_set.add("PHP");
tree_set.add("SFDC");
// Display TreeSet
System.out.println("TreeSet: " + tree_set);
// By using first() method is to return
// the first least element exists in this TreeSet
Object first_least = tree_set.first();
// Display first_least
System.out.println("tree_set.first(): " + first_least);
}
}

Output

输出量

TreeSet: [C, C++, JAVA, PHP, SFDC]
tree_set.first(): C

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

treeset java

treeset java_Java TreeSet first()方法与示例相关推荐

  1. treeset java_Java TreeSet pollLast()方法与示例

    treeset java TreeSet类pollLast()方法 (TreeSet Class pollLast() method) pollLast() method is available i ...

  2. treeset java_Java TreeSet add()方法与示例

    treeset java TreeSet类的add()方法 (TreeSet Class add() method) add() method is available in java.util pa ...

  3. treeset java_Java TreeSet clear()方法与示例

    treeset java TreeSet类的clear()方法 (TreeSet Class clear() method) clear() method is available in java.u ...

  4. treeset java_Java TreeSet last()方法与示例

    treeset java TreeSet类的last()方法 (TreeSet Class last() method) last() method is available in java.util ...

  5. treeset java_Java TreeSet Higher()方法与示例

    treeset java TreeSet类Higher()方法 (TreeSet Class higher() method) higher() method is available in java ...

  6. treeset java_Java TreeSet iterator()方法与示例

    treeset java TreeSet类的iterator()方法 (TreeSet Class iterator() method) iterator() method is available ...

  7. treeset java_Java TreeSet ceiling()方法与示例

    treeset java TreeSet类ceiling()方法 (TreeSet Class ceiling() method) ceiling() method is available in j ...

  8. treeset比较器_Java TreeSet比较器()方法与示例

    treeset比较器 TreeSet类的compare()方法 (TreeSet Class comparator() method) comparator() method is available ...

  9. drawimage的用法 java_Java Graphics.drawImage方法代码示例

    本文整理汇总了Java中javax.microedition.lcdui.Graphics.drawImage方法的典型用法代码示例.如果您正苦于以下问题:Java Graphics.drawImag ...

最新文章

  1. 学生课程表管理系统——stage 1
  2. HDFS的Java客户端操作代码(HDFS删除文件或目录)
  3. c#创建web应用程序_创建Web应用程序图标集的6个步骤
  4. 信息学奥赛一本通C++语言——1102: 与指定数字相同的数的个数
  5. 如何在ASP.NET Core中上传文档
  6. event.srcElement 与event.target
  7. 诹图系列(2): 堆积条形图
  8. 深度神经网络为何很难训练
  9. 最好的git教程,没有之一
  10. 字母c语言教学课件,计算机二级考试C语言辅导课件.ppt
  11. Python题目:判断101-200之间有多少个素数,并输出所有素数,简单方法
  12. PS利用色彩范围抠图
  13. 发送、抄送、密送、分别发送、回复、回复全部、转发的区别(一篇文章研究透彻)
  14. java课程结课论文_Java技术综合课程设计论文
  15. Moebius for SQL Server
  16. work profile关闭时桌面图标变灰
  17. 我的世界修改服务器视距,教程/测量距离 - Minecraft Wiki,最详细的官方我的世界百科...
  18. amCharts 报表(转)
  19. 基于Arduino的PS2机械臂遥控小车(L298N)傻瓜教程
  20. ubuntu修改u盘权限_Ubuntu下的U盘只读文件系统,该图标已锁定,表明无法对其进行修改...

热门文章

  1. 【SpringBoot 2】(三)SpringBoot相较于Spring的特点
  2. JDK源码解析之Java.util.Collection
  3. 将z-blog改成英文blog所遇到的问题
  4. python操作三大主流数据库(12)python操作redis的api框架redis-py简单使用
  5. CentOS 7.1下KVM的安装与配置
  6. android 事件分发
  7. windows server 2008 IE代理服务器实验
  8. [转]Install Windows Server 2012 in VMware Workstation
  9. 用于检测敏感词的 PHP 扩展
  10. linux 调优 网络调优