public class HelloClass {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
// Long l = null;
String str="32145679a";
try {
Long l = Long.parseLong(str);
System.out.println(l);
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("出现非法字符.......");
}finally{
System.out.println("出现非法字符...悲剧了...");
}
}
}
最后输出:java.lang.NumberFormatException: For input string: "32145679a"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Long.parseLong(Long.java:412)
at java.lang.Long.parseLong(Long.java:461)
at HelloClass.main(HelloClass.java:13)
出现非法字符.......
出现非法字符...悲剧了...
都已经捕获了怎么还会出现错误呢??? |