簡體   English   中英

ArrayIndexOutOfBoundsException:索引 30 超出長度 30 的范圍

[英]ArrayIndexOutOfBoundsException: Index 30 out of bounds for length 30

更新:原來我不得不再次導出 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);
}

ArrayIndexOutOfBoundsException: Index 30 out of bounds for length 30意味着你有一個長度為 30 的數組並試圖訪問索引 30 處的元素。但有效的索引范圍是 0-29。

從上面的代碼中無法看出異常來自哪里。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM