gpt4 book ai didi

java - 在 intelliJ 中突出显示未检查的异常

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:35:55 25 4
gpt4 key购买 nike

我正在从 eclipse 迁移到 intelliJ,但我偶然发现了 catch 子句中异常的突出显示问题。这有点链接到 Highlight exception throwers in IntelliJ IDEA

给出示例代码如下:

try {
System.out.print(Double.parseDouble("throws exception"));
} catch (NumberFormatException e){
System.out.print(e.toString());
}

并将光标定位在 eclipse 中的 NumberFormatException 上将突出显示它被抛出的位置,如

enter image description here

但在 intelliJ 中我无法重现:enter image description here

当我将插入符放在 catch 和 NumberFormatException 上时,我已经尝试过 highlight usage in file 但它不起作用,我做错了什么?

在方法签名中做也是一样的, eclipse :

enter image description here

但不在 intelliJ 中

enter image description here

是否可以像在eclipse中一样获取这个?

编辑

正如 yole 在其中一个答案中所解释的,这特定于 IntelliJ 中的未经检查的异常,即使它们是在方法签名中声明的,例如 Double.parseDouble(String) throws NumberFormatException()

最佳答案

在 IntelliJ IDEA 中,要查看抛出异常的位置,您需要将插入符放在 catch 关键字上,而不是异常类名上。

关于java - 在 intelliJ 中突出显示未检查的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42672360/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com