打印堆栈跟踪 [英] Printing the stacktrace
本文介绍了打印堆栈跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从我们的文章中获取了异常代码。
我刚刚修改了代码并尝试运行它。
但它骂我......如下:
MyException.java:44:'''''这里不允许这种类型
System.err.println(" test:" + e.printStackTrace());
^
1错误
请阅读程序......
I get the code from our articles for exception.
I just modified the code and tried to run it.
But it scold me..as follows.
MyException.java:44: ''void'' type not allowed here
System.err.println("test : "+e.printStackTrace());
^
1 error
Kindly read the program...
展开 | 选择 | Wrap | 行号
推荐答案
我从我们的文章中获取异常代码。
我刚刚修改了代码并尝试运行它。
但它骂我......如下:
MyException.java:44:'''''这里不允许这种类型
System.err.println(" test:" + e.printStackTrace());
^
1错误
请阅读程序......
I get the code from our articles for exception.
I just modified the code and tried to run it.
But it scold me..as follows.
MyException.java:44: ''void'' type not allowed here
System.err.println("test : "+e.printStackTrace());
^
1 error
Kindly read the program...
展开 | 选择 | Wrap | 行号
printStackTrace方法没有返回任何内容(void)所以它不能在表达式中使用
。只需用它作为陈述。
亲切的问候,
Jos
The printStackTrace method doesn''t return anything (void) so it can not be used
in an expression. Just use it as a statement.
kind regards,
Jos
e.printStackTrace( )是无效但你试图将它用作+运算符的右操作数。
打开Exception的API文档,你会看到返回Strings的所有方法。只需选择一个你想要的。
e.printStackTrace() is void but you are trying to use it as a right operand for the + operator.
Open the API docs for Exception and you''ll see all the methods that return Strings. Just pick one that you want.
这篇关于打印堆栈跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文