JavaSE8基础 Integer构造方法 将符合标准的String类型转成int类型
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JavaSE8基础 Integer构造方法 将符合标准的String类型转成int类型相关的知识,希望对你有一定的参考价值。
os :windows7 x64
jdk:jdk-8u131-windows-x64
ide:Eclipse Oxygen Release (4.7.0)
code:
package jizuiku3; public class Demo000 { public static void main(String[] args) { //字符串符合int规则的 Integer n = new Integer("124567"); System.out.println(n); // 也会抛异常的代码 // Integer n1 = new Integer("124567.44"); // System.out.println(n1); //字符串不符合int规则的,会抛异常的 Integer n2 = new Integer("124567a"); System.out.println(n2); } }
result:
Java优秀,值得学习。
学习资源:API手册+Java源码+清净的心地。
以上是关于JavaSE8基础 Integer构造方法 将符合标准的String类型转成int类型的主要内容,如果未能解决你的问题,请参考以下文章