【发布时间】:2018-07-20 14:27:32
【问题描述】:
Float f1 = new Float("12.6f");
在上面的代码中,我没有遇到任何异常。但是我得到了下面的代码
NumberFormatException:
Long l1= new Long("200L");
我知道除了 Character 之外的所有包装类都提供了两个构造函数
Integer i1 = new Integer(42); //Primitive
Integer i2 = new Integer("42"); // String
Float f1 = new Float(3.14f); //Primitive
Float f2 = new Float("3.14f"); // String
那么为什么我会得到例外
Long l1= new Long("200L");
为什么没有
Float f2 = new Float("3.14f");
【问题讨论】:
标签: java wrapper numberformatexception