List<Integer> intList = strList.stream().map(Integer::parseInt).collect(Collectors.toList());


public static void main(String[] args) {
List<String> strList = new ArrayList<String>();
strList.add("1");
strList.add("2");
strList.add("3");
strList.add("4");
strList.add("5");
strList.add("6");
for (String str : strList) {
System.out.println("这是String类型:" + str);
}
System.out.println("+++++++++++++++++++++++++++++++++");
List<Integer> intList = strList.stream().map(Integer::parseInt).collect(Collectors.toList());
for (Integer code : intList) {
System.out.println("这是Integer类型:"+code);
}

方法二:mapToInt


List<Integer> intStream = strList.stream().mapToInt(Integer::parseInt).boxed().collect(Collectors.toList());

List<String>转List<Integer>的更多相关文章

  1. Integer.valueof(String s)和Integer.parseInt(String s)的具体区别是什么?

    Integer.valueof(String s)和Integer.parseInt(String s)的具体区别是什么? Integer.valueof(String s)是将一个包装类是将一个实际 ...

  2. Integer.parseInt(String s) 和 Integer.valueOf(String s) 的区别

    通过查看java.lang.Integer的源码可以发现, 它们最终调用的都是 /** * Parses the string argument as a signed integer in the ...

  3. String和包装类Integer\Double\Long\Float\Character 都是final类型

    String和包装类Integer\Double\Long\Float\Character\Boolean 都是final类型 不可以改变

  4. java5核心基础之泛型(3)-泛型作用于编译阶段-怎样将String对象传入Integer类型的泛型对象中?

    泛型作用于编译阶段: 泛型是作用于编译阶段,在编译阶段控制类型,以确保在编写代码的时候仅仅能传入指定类型数据到泛型集合对象中去. 怎样验证呢,贴代码例如以下: package highBasic.ge ...

  5. [TS] Parse a string to an integer

    A common interview question is to write
 a
function
that
converts
 a
 string
into
an
integer e.g. &q ...

  6. [string]Roman to Integer,Integer to Roman

    一.Roman to Integer Given a roman numeral, convert it to an integer. Input is guaranteed to be within ...

  7. Hex string convert to integer with stringstream

    #include <sstream>#include <iostream>int main() { unsigned int x; std::stringstream ss; ...

  8. [LeetCode] String to Integer (atoi) 字符串转为整数

    Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. ...

  9. No.008:String to Integer (atoi)

    问题: Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input ca ...

随机推荐

  1. php--laravel --debug--mac

    1>安装debug 一.下载xdebug文件 1.将phpinfo();的信息全部输入网址中的框,得到适配的xdebug版本: 网址:http://xdebug.org/wizard.php 2 ...

  2. P4548-[CTSC2006]歌唱王国【概率生成函数,KMP】

    正题 题目链接:https://www.luogu.com.cn/problem/P4548 题目大意 \(t\)次询问,给出一个长度为\(m\)的串\(S\)和一个空串\(T\),每次在\(T\)后 ...

  3. AT3949-[AGC022D]Shopping【贪心】

    正题 题目链接:https://www.luogu.com.cn/problem/AT3949 题目大意 长度为\(L\)的坐标轴上,给出\(n\)个点,每个点\(x_i\)需要购物\(t_i\)的时 ...

  4. serialVersionUID序列化版本号与ObjectOutputStream对象输入输出流

    1. 观察ObjectOutputStream 我们观察ObjectOutputStream就可以发现该类没有无参构造,只有有参构造,所以他是一个包装流 2. 具体使用: public static ...

  5. Ubuntu-mate-20.04-desktop安装总结

    ubuntu-mate-20.04-desktop效果先展示下: Ubuntu用MATE桌面环境同时配合compiz 窗口管理器是目前为止得到的桌面中最喜欢的样式 一.ubuntu-mate官网下载i ...

  6. 解决连接云服务器的redis失败

    在本地连接服务器redis的时候,发现连接失败,这是因为服务器上的redis开启保护模式运行,该模式下是无法进行远程连接的.只需要修改redis目录下的redis.conf文件,找到 protecte ...

  7. FastAPI 学习之路(四)

    系列文章: FastAPI 学习之路(一)fastapi--高性能web开发框架 FastAPI 学习之路(二) FastAPI 学习之路(三) 之前的文章分享了如何去在请求中增加参数,本文我们将分享 ...

  8. 【UE4 C++】UObject 创建、销毁、内存管理

    UObject 的创建 NewObject 模板类 本例使用 UE 4.26,只剩下 NewObject 用来创建 UObject,提供两个带不同可选参数构造函数的模板类 Outer 表示这个对象的外 ...

  9. 【UE4 C++】解析与构建 XML 数据,XmlParser 与 tinyxml

    XmlParser 简单读取 XmlParser 为引擎自带模块 XML 文件 <?xml version="1.0" encoding="UTF-8"? ...

  10. 在kivy中加图片

    from kivy.app import App from kivy.uix.scatterlayout import ScatterLayout from kivy.uix.image import ...