報錯String index out of range是什麼意思?使用者3646512562287342019-10-23 21:39:01

給出的程式碼只會出現異常java。lang。IndexOutOfBoundsException: Index: 0, Size: 0,但是你的是String index out of range: -1,這個是說字元索引越界了。給你兩個例子說明:‍java。lang。IndexOutOfBoundsException: Index: 0, Size: 012345678910 import java。util。ArrayList;import java。util。List;public class Test { public static void main(String[] args) { List