之前每次都是通过循环去写,感觉代码不够优雅,百度了一下,查到如下的写法,先记下来:

List<Long> list = new ArrayList<Long>();  

list.add(1L);  

list.add(2L);  

list.add(3L);  

System.out.println(list);  

long [] array = list.stream().mapToLong(t->t.longValue()).toArray();

List<Long> list = new ArrayList<Long>();  

list.add(1L);  

list.add(2L);  

list.add(3L);  

System.out.println(list);  

long [] array = list.stream().mapToLong(t->t.longValue()).toArray();

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-22
  • 2022-12-23
  • 2022-12-23
  • 2021-09-19
  • 2022-01-10
猜你喜欢
  • 2022-02-05
  • 2021-08-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案