在尝试调试以下块时,IntelliJ出错:
1. private boolean compareMatrices(Map<String, Map<String, Double> toCompare) {
2. for (String c1 : this.keySet()) {
3. Map<String, Double> thisRow = this.get(c1);
4. Map<String, Double> otherRow = toCompare.get(c1);
5.
6. for (Entry<String, Double> cell : thisRow.entrySet())
7. if (!otherRow.get(cell.getKey()).equals(cell.getValue()))
8. return false;
9. }
10. return true;
11. }我在第7行放置了一个带有条件otherRow.get(cell.getKey()) == null的断点,并在命中断点时从调试器获取"Cannot find local variable cell"错误。如果我将for块(第6-8行)括在大括号中,则不会发生此错误,如下所示:
1. private boolean compareMatrices(Map<String, Map<String, Double> toCompare) {
2. for (Stringc1 : this.keySet()) {
3. Map<String, Double> thisRow = this.get(c1);
4. Map<String, Double> otherRow = toCompare.get(c1);
5.
6. for (Entry<String, Double> cell : thisRow.entrySet()) {
7. if (!otherRow.get(cell.getKey()).equals(cell.getValue()))
8. return false;
10. }
10. }
11. return true;
12. }我的问题是,这个错误是来自我可能犯的配置错误,还是与IntelliJ对Java语法的错误解释有关?另外,条件断点是否会显著降低调试器的速度?当使用上面的第二个版本时,调试器将正确执行,但花费的时间是正常执行时的十倍以上。
发布于 2022-04-23 22:36:40
您的代码是有效的java,因此它不可能是配置错误。我怀疑这是不是IntelliJ的错误。我猜你:
括号编译了程序
执行行。
现在您的源代码与编译的源代码不匹配,因此出现了错误。
停止执行,用第一个版本的代码重新构建项目,然后再试着调试它。
同时,条件断点是否会显著降低调试器的速度?
是的,有可能。字段和方法断点也明显慢于“常规”断点。
https://stackoverflow.com/questions/71983584
复制相似问题