line number is important in Exceptions.
行号作为debug信息
在出现异常时可以迅速定位
package ztest; public class Test { public static void main(String[] args) { int a = 1/1; int b = 1/2; int c = 1/3; int d = 1/4; int e = 1/0; int f = 1/6; int g = 1/7; } }
Exception in thread "main" java.lang.ArithmeticException: / by zero
at ztest.Test.main(Test.java:9)
解读
- 异常信息出现在 "main" 线程
- 位置是 ztest.Test (类的全限定名 )的 main (方法)(Test.java 文件的第9行)
反编译后的class是:
这里的行号是指 java 源文件中的行号 Ctrl+L 可打开
增加/删除任何行,包括空行注释等,都会影响行号
package ztest; public class Test { public static void main(String[] args) { int a = 1/1; int b = 1/2; int c = 1/3; int d = 1/4; int e = 1/0; int f = 1/6; int g = 1/7; } }
Exception in thread "main" java.lang.ArithmeticException: / by zero
at ztest.Test.main(Test.java:13)