gpt4 book ai didi

java - 找不到符号抛出 IndexOutOfBoundException

转载 作者:行者123 更新时间:2023-11-29 07:00:17 24 4
gpt4 key购买 nike

我有以下简单的类:

public class Polynomial {
private double[] c;
public double get(int i) throws IndexOutOfBoundException { return c[i]; }
public void set(int i, double a) throws IndexOutOfBoundException, ArithmeticException { c[i] = a; }
}

编译时出现此错误:

Polynomial.java:39: error: cannot find symbol
public double get(int i) throws IndexOutOfBoundException { return c[i]; }
^
symbol: class IndexOutOfBoundException
location: class Polynomial
Polynomial.java:42: error: cannot find symbol
public void set(int i, double a) throws IndexOutOfBoundException, ArithmeticException { c[i] = a; }
^
symbol: class IndexOutOfBoundException
location: class Polynomial
2 errors

为什么我得到 cannot find symbol 异常 IndexOutOfBoundException?距离上次我用 Java 编程已经有一段时间了,但我没有发现任何问题。

最佳答案

IndexOutOfBoundsException,不是IndexOutOfBoundException

你少了一个S

关于java - 找不到符号抛出 IndexOutOfBoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27295834/

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