zoukankan      html  css  js  c++  java
  • Arrays.asList()

    Arrays.asList()方法接受一个数组或者是一个用逗号分隔的元素列表(可以使用可变参数),并将其转换成一个List对象。

    用法示例:

    //: holding/AddingGroups.java
    // Adding groups of elements to Collection objects.
    import java.util.*;
    
    public class AddingGroups {
      public static void main(String[] args) {
        Collection<Integer> collection =
          new ArrayList<Integer>(Arrays.asList(1, 2, 3, 4, 5)); /*1*/
        Integer[] moreInts = { 6, 7, 8, 9, 10 };
        collection.addAll(Arrays.asList(moreInts)); /*2*/
        // Runs significantly faster, but you can't
        // construct a Collection this way:
        Collections.addAll(collection, 11, 12, 13, 14, 15);
        Collections.addAll(collection, moreInts);
        // Produces a list "backed by" an array:
        List<Integer> list = Arrays.asList(16, 17, 18, 19, 20); /*3*/
        list.set(1, 99); // OK -- modify an element
        // list.add(21); // Runtime error because the
                         // underlying array cannot be resized.
      }
    } ///:~
    
  • 相关阅读:
    python模拟shell
    10.LIKE 操作符
    9.TOP 子句--mysql limit
    8.INSERT INTO 语句 UPDATE 语句
    7.ORDER BY 子句
    6.AND & OR 运算符
    5.WHERE 子句
    4.SELECT DISTINCT 语句
    3.SELECT 语句
    2.sql分类
  • 原文地址:https://www.cnblogs.com/fanlumaster/p/13661604.html
Copyright © 2011-2022 走看看