【问题标题】:ArrayIndexOutOfBoundsException: Index 30 out of bounds for length 30ArrayIndexOutOfBoundsException:索引 30 超出长度 30 的范围
【发布时间】:2021-11-14 12:32:27
【问题描述】:

更新:结果我不得不再次导出 SVG 并将其放入文件的数据文件夹中。

我又遇到了一个编码问题。 抱歉,如果格式不正确,我还没有改进我对编码问题的措辞方式。

ArrayIndexOutOfBoundsException : Index 30 out of bounds for length 30 是什么意思?我已经尝试自己查找它,但我似乎无法找到含义。

起初,当我添加我的 svg 时,代码正在运行,然后我再次添加了相同的文件并且它也正在运行(Eye2,pupil2,lash2),然后我添加了 Nose.SVG 文件,我突然收到了一个错误.

我正在处理 4.0 中编码

这是我得到的错误,我也复制粘贴了所有代码。

ArrayIndexOutOfBoundsException:索引 30 超出长度 30 的范围

-- 我似乎找不到我的堆栈跟踪

PShape Eye;
PShape Pupil;
PShape Lash;
PShape Eye2;
PShape Pupil2;
PShape Lash2;
PShape Mouth;
PShape Line;
PShape Nose;

void setup() {
  size(1000, 1000);
  Eye = loadShape("Eye.svg");
  Pupil= loadShape("Pupil.svg");
  Lash= loadShape("Lash.svg");
  Mouth= loadShape("Mouth.svg");
  Line= loadShape("Line.svg");
  Nose= loadShape("Nose.svg");
  Eye2 = loadShape("Eye.svg");
  Pupil2= loadShape("Pupil.svg");
  Lash2= loadShape("Lash.svg");
}

void draw() {
  background(230, 230, 250);

  shape(Nose, 110, 90, 200, 200);


  Eye.disableStyle();
  fill( 173, 216, 230);
  stroke( 173, 216, 230);
  shape(Eye, 110, 90, 400, 400);


  Pupil.disableStyle();
  fill( 255, 140, 0);
  stroke( 255, 140, 0);
  shape(Pupil, 220, 200, 200, 200);

  shape(Lash, 90, 10, 400, 400);


  Eye2.disableStyle();
  fill( 173, 216, 230);
  stroke( 173, 216, 230);
  shape(Eye2, 500, 90, 400, 400);


  Pupil2.disableStyle();
  fill( 255, 140, 0);
  stroke( 255, 140, 0);
  shape(Pupil2, 620, 200, 200, 200);

  shape(Lash2, 500, 10, 400, 400);


  Mouth.disableStyle();
  fill(192, 238, 144);
  stroke(192, 238, 144);
  shape(Mouth, 280, 400, 400, 450);

  shape(Line, 280, 400, 350, 350);
}

【问题讨论】:

  • 请编辑问题并显示完整的错误堆栈。谢谢
  • 请添加堆栈跟踪

标签: java arrays processing


【解决方案1】:

ArrayIndexOutOfBoundsException : Index 30 out of bounds for length 30 表示您有一个长度为 30 的数组并试图访问索引为 30 的元素。但有效的索引范围是 0-29。

从上面的代码无法看出异常是从哪里来的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-18
    • 1970-01-01
    • 2020-10-24
    • 1970-01-01
    相关资源
    最近更新 更多