综合练习2:数据类型转换异常
编写一个简单程序,使之产生数据类型转换异常(NumberFormatException)
/*综合练习2:数据类型转换异常
* 编写一个简单程序,使之产生数据类型转换异常(NumberFormatException)
* */
package yccl;
public class Zhlx2 {
public static void main(String[] args) {
// TODO 自动生成的方法存根
try {
String a = "1234.0";
int b = Integer.parseInt(a);
System.out.println(b);
}catch(Exception e) {
System.out.println(e);
}
}
}