如何抛出RuntimeException(“找不到符号”) [英] How to throw RuntimeException ("cannot find symbol")
本文介绍了如何抛出RuntimeException(“找不到符号”)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
throw RuntimeException(msg);
但是当我构建NetBeans时,我收到以下错误:
C:\ .... java:50:找不到符号
符号:方法RuntimeException(java.lang.String)
位置: class ...
throw RuntimeException(msg);
1错误
我需要导入东西吗?我拼错了吗?我确定我一定要做一些愚蠢的事情: - (
解决方案
throw new RuntimeException(msg)
您需要新的
,它创建一个实例并抛出,不调用方法。
I'm trying to throw an exception in my code like this:
throw RuntimeException(msg);
But when I build in NetBeans I get this error:
C:\....java:50: cannot find symbol
symbol : method RuntimeException(java.lang.String)
location: class ...
throw RuntimeException(msg);
1 error
Do I need to import something? Am I misspelling it? I'm sure I must be doing something dumb :-(
解决方案
throw new RuntimeException(msg)
You need the new
in there. It's creating an instance and throwing it, not calling a method.
这篇关于如何抛出RuntimeException(“找不到符号”)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文