zoukankan      html  css  js  c++  java
  • 数组和集合转化 array与list

    package com.chen.test;

    import java.io.Serializable;
    import java.util.Arrays;
    import java.util.List;
    import java.util.stream.Collectors;

    public class Test {

    public static void main(String [] args)
    {
    System.out.println("你好");


    Integer [] arrs=new Integer[]{1,3,4,6,6};
    //打印
    System.out.println(Arrays.toString(arrs));

    //转化List
    List<Integer> integers = Arrays.asList(arrs);
    System.out.println(integers);

    //转化数组
    Integer[] integers1 = integers.toArray(new Integer[0]);
    System.out.println(Arrays.toString(integers1));


    //基本数组转化集合
    int [] arrs2={9,6,3,5,7};
    List<Integer> collect = Arrays.stream(arrs2).boxed().collect(Collectors.toList());
    System.out.println(collect);


    //多参数转化集合
    List<? extends Serializable> list = Arrays.asList("你好",1000, 500);
    System.out.println(list);

    }

    }

  • 相关阅读:
    [zoj3627]模拟吧
    [zoj3623]背包模型
    [hdu4358]树状数组
    [hdu1272]并查集
    [hdu3308]线段树
    [hdu5033]单调队列
    [hdu1506]单调队列(栈)
    [hdu2888]二维RMQ
    [hdu4123]dfs区间化+RMQ
    [hdu1242]优先队列
  • 原文地址:https://www.cnblogs.com/chxl800/p/11558276.html
Copyright © 2011-2022 走看看