我在我的第一類Java編程中,我們給出的一個賦值是創建一個值字符串,它以相反的順序顯示逗號。我知道我可能錯過了一些非常簡單的事情,但經過幾個小時的努力,我只是不知道自己的錯在哪裏?錯誤消息:線程「main」中的異常java.lang.ArrayIndexOutOfBoundsException:-1
我的代碼工作,但我不斷收到此錯誤信息:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
at ip2_jolley.IP2_Jolley.main(IP2_Jolley.java:148)
Three, Two, One Java Result: 1
這是我使用的代碼:
String[] f = {"One", "Two", "Three"};
if (f.length > 0) System.out.print (f[2]);
for (int i = 1; i < f.length; i--){
System.out.print(", " + f[i]);
}
它不會讓我點擊向上箭頭,所以我編輯,以感謝他們。 – Violette
..當時我也不允許發表評論。 – Violette