首页 >> 精选知识 >

string index out of range什么意思(string index out of range)

2024-01-20 23:20:05  来源:网易  用户: 
📌 本文为历史内容整理发布,信息仅供参考,请以最新信息为准。

大家好,小奥来为大家解答以上的问题。string index out of range什么意思,string index out of range这个很多人还不知道,现在让我们一起来看看吧!

1、给出的代码只会出现异常java.***.indexoutofboundsexception: Index: 0, Size: 0,但是你的是String index out of range: -1,这个是说字符索引越界了。

2、给你两个例子说明:‍java.***.indexoutofboundsexception: Index: 0, Size: 012345678910 import java.***.arraylist;import java.***.list;public class Test { public static void main(String[] args) { List list = new ArrayList(); ***.get(0);// String str = "abc";// ***.sub***ing(4); }}结果:2、java.***.stringindexoutofboundsexception: String index out of range:-112345678910 import java.***.arraylist;import java.***.list;public class Test { public static void main(String[] args) {// List list = new ArrayList();// ***.get(0); String str = "abc"; ***.sub***ing(4);。

本文到此分享完毕,希望对大家有所帮助。

免责声明:本文由用户上传,与本网站立场无关。财经信息仅供读者参考,并不构成投资建议。投资者据此操作,风险自担。 如有侵权请联系删除!

最新文章