博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
java 方法 示例_Java集合checkedList()方法与示例
阅读量:2539 次
发布时间:2019-05-11

本文共 2283 字,大约阅读时间需要 7 分钟。

java 方法 示例

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

  • checkedList() Method is available in java.lang package.

    CheckedList()方法在java.lang包中可用。

  • checkedList() Method is used to return the typesafe view of the given List at runtime.

    checkedList()方法用于在运行时返回给定List的类型安全视图。

  • checkedList() Method is a static method, so it is accessible with the class name and if we try to access the method with the class object then we will not get an error.

    CheckedList()方法是静态方法,因此可以使用类名进行访问,如果尝试使用类对象访问该方法,则不会收到错误。

  • checkedList() Method does not throw an exception at the time of returning validated List.

    CheckedList()方法在返回经过验证的List时不会引发异常。

Syntax:

句法:

public static List checkedList(List l, Class ele_ty);

Parameter(s):

参数:

  • List l – represents the list for which to get typesafe view at runtime.

    列表l –表示在运行时获取类型安全视图的列表。

  • Class ele_ty – represents the element type (ele_ty) that the given List is allowed to store.

    ele_ty类 –表示允许存储给定List的元素类型(ele_ty)。

Return value:

返回值:

The return type of the method is List, it returns typesafe or validated view of the given List dynamically.

方法的返回类型为List ,它动态返回给定List的类型安全或经过验证的视图。

Example:

例:

// Java Program is to demonstrate the example// of List checkedList(List l, Class ele_ty) of Collections classimport java.util.*;public class CheckedList {
public static void main(String args[]) {
// Create a linked list object LinkedList < Integer > link_list = new LinkedList < Integer > (); // By using add() method is to add the // given elements in linked list link_list.add(20); link_list.add(10); link_list.add(30); link_list.add(40); link_list.add(50); // Display LinkedList System.out.println("link_list: " + link_list); // By using checkedList() method is to // represent the type safe view of the given // Collection linked list Collection < Integer > co = Collections.checkedList(link_list, Integer.class); System.out.println(); System.out.println("Collections.checkedList(link_list, Integer.class) :"); // Display collection System.out.println("co: " + co); }}

Output

输出量

link_list: [20, 10, 30, 40, 50]Collections.checkedList(link_list, Integer.class) :co: [20, 10, 30, 40, 50]

翻译自:

java 方法 示例

转载地址:http://jixzd.baihongyu.com/

你可能感兴趣的文章
HDU5447 Good Numbers
查看>>
08.CXF发布WebService(Java项目)
查看>>
java-集合框架
查看>>
RTMP
查看>>
求一个数的整数次方
查看>>
点云PCL中小细节
查看>>
铁路信号基础
查看>>
RobotFramework自动化2-自定义关键字
查看>>
[置顶] 【cocos2d-x入门实战】微信飞机大战之三:飞机要起飞了
查看>>
BABOK - 需求分析(Requirements Analysis)概述
查看>>
第43条:掌握GCD及操作队列的使用时机
查看>>
Windows autoKeras的下载与安装连接
查看>>
CMU Bomblab 答案
查看>>
微信支付之异步通知签名错误
查看>>
2016 - 1 -17 GCD学习总结
查看>>
linux安装php-redis扩展(转)
查看>>
Vue集成微信开发趟坑:公众号以及JSSDK相关
查看>>
技术分析淘宝的超卖宝贝
查看>>
i++和++1
查看>>
react.js
查看>>