集合类unmodifiableSortedSet()方法 (Collections Class unmodifiableSortedSet() method)

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

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

  • unmodifiableSortedSet() method is used to get a non-modifiable view of the given SortedSet (ss).

    unmodifiableSortedSet()方法用于获取给定SortedSet(ss)的不可修改视图。

  • unmodifiableSortedSet() method is a static method, it is accessible with the class name and if we try to access the method with the class object then also we will not get any error.

    unmodifiableSortedSet()方法是一个静态方法,可以使用类名进行访问,如果尝试使用类对象访问该方法,那么也不会出现任何错误。

  • unmodifiableSortedSet() method does not throw an exception at the time of returning unmodifiable view of the given sorted set.

    在返回给定排序集的不可修改视图时, unmodifiableSortedSet()方法不会引发异常。

Syntax:

句法:

    public static SortedSet unmodifiableSortedSet(SortedSet ss);

Parameter(s):

参数:

  • SortedSet ss – represents the sorted set object for which a non-modifiable view is to be retrieved.

    SortedSet ss –表示要检索其不可修改视图的排序集对象。

Return value:

返回值:

The return type of this method is SortedSet, it returns an unmodifiable view of the given sorted set.

此方法的返回类型为SortedSet ,它返回给定排序集的不可修改的视图。

Example:

例:

// Java program to demonstrate the example
// of SortedSet unmodifiableSortedSet()
// method of Collections
import java.util.*;
public class UnmodifiableSortedSetOfCollections {public static void main(String args[]) {// Instantiates a sorted set object
SortedSet < Integer > ss = new TreeSet < Integer > ();
// By using add() method is to add
//objects in a sorted set
ss.add(20);
ss.add(10);
ss.add(40);
ss.add(30);
ss.add(50);
// Display Sorted Set
System.out.println("SortedSet: " + ss);
// By using unmodifiableSortedSet() method is to
// represent the tree set in unmodifiable view
ss = Collections.synchronizedSortedSet(ss);
// We will get an exception when we
// try to add an object in an unmodifiable
// sorted set
/* ss.add(60)*/
}
}

Output

输出量

SortedSet: [10, 20, 30, 40, 50]

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

Java集合unmodifiableSortedSet()方法(带示例)相关推荐

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

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

  2. java集合代码_Java-集合(示例代码)

    一.Java集合框架概述 ●一方面,面向对象语言对事物的体现都是以对象的形式,为了方便对多个对象的操作,就要对对象进行存储.另一方面,使用Array存储对象方面具有一些弊端,而Java集合就像一种容器 ...

  3. java集合的方法及使用详解

    一.java集合的分类及相互之间的关系 Collection接口:向下提供了List和Set两个子接口 |------List接口:存储有序的,存储元素可以重复 |------ArrayList(主要 ...

  4. java getmonth_Java LocalDateTime类| 带示例的getMonth()方法

    java getmonth LocalDateTime类getMonth()方法 (LocalDateTime Class getMonth() method) getMonth() method i ...

  5. java集合list方法吗_关于集合:将List转换为Java集合的最简单方法

    在Java中,将EDCOX1的0度转换为EDCOX1×1的最简单的方法是什么? Set foo = new HashSet(myList); @阿什什:这与这个问题完全无关.没有人问如何将空值转换为集 ...

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

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

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

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

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

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

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

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

最新文章

  1. 721合约 erc eth_深入了解「智能合约」及主流平台「智能合约」的查询方法
  2. dw网页设计作品_10个富有特色的网页设计精选作品
  3. 计算机类和鼠标类是什么关系,常见鼠标的种类
  4. super icon
  5. 原生APP与web APP的区别
  6. 安全研究剖析:******方式演示
  7. 图解“红黑树”原理,一看就明白!
  8. 聊一聊如何在.NET Core中使用Nacos 2.0
  9. python 时间_Python-基础-时间日期处理小结
  10. python import from区别_python中import与from方法总结(推荐)
  11. 【NOIP2002】【Luogu1032】字串变换
  12. [debug] RuntimeError: “nll_loss_forward_reduce_cuda_kernel_2d_index“ not implemented for ‘Int‘
  13. 计算机视觉实战(六)边缘检测
  14. 解决gitlab内存占用过多的问题
  15. 用diiv实现多个方块居中嵌套--padding
  16. 如何关闭笔记本电脑触摸板功能
  17. tms xdata、sparkle服务运行时显示拒绝访问的错误
  18. C/C++条件运算符你不知道的那些事
  19. 使用android新特性:Material Design
  20. 关于TeX,LaTeX,MikTex,CTeX,etc.

热门文章

  1. matlab三维选取二维,基于Matlab绘制二维和三维图形以及其他图形控制函数的使用方法...
  2. 如何仅通过CSS实现多行文本超长自动省略号
  3. CSS3之background的调整和增加的属性
  4. Css Secret 案例Demo全套
  5. css清除浮动的原理
  6. TypeScript类型推论(Type Inference)
  7. 在React中获取数据
  8. matplotlib散点图笔记
  9. linux线程基础篇----线程同步与互斥
  10. tornado-简介和原理