晴川云鸿蒙OS教程:鸿蒙OS StringIndexOutOfBoundsException

StringIndexOutOfBoundsException

java.lang.Object

|—java.lang.Throwable

|—|—java.lang.Exception

|—|—|—java.lang.RuntimeException

|—|—|—|—java.lang.IndexOutOfBoundsException

|—|—|—|—|—java.lang.StringIndexOutOfBoundsException

public class StringIndexOutOfBoundsException
extends IndexOutOfBoundsException

由 String 方法抛出以指示索引为负数或大于字符串的大小。 对于某些方法,例如 charAt 方法,当索引等于字符串的大小时也会引发此异常。

构造函数摘要

构造函数 描述
StringIndexOutOfBoundsException() 构造一个没有详细消息的 StringIndexOutOfBoundsException。
StringIndexOutOfBoundsException(int index) 使用指示非法索引的参数构造一个新的 StringIndexOutOfBoundsException 类。
StringIndexOutOfBoundsException(String s) 使用指定的详细消息构造 StringIndexOutOfBoundsException。

方法总结

从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
从类 java.lang.Throwable 继承的方法
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString

构造函数详细信息

StringIndexOutOfBoundsException

public StringIndexOutOfBoundsException()

构造一个没有详细消息的 StringIndexOutOfBoundsException。

StringIndexOutOfBoundsException

public StringIndexOutOfBoundsException(String s)

使用指定的详细消息构造 StringIndexOutOfBoundsException。

参数:

参数名称 参数描述
s 详细信息。

StringIndexOutOfBoundsException

public StringIndexOutOfBoundsException(int index)

使用指示非法索引的参数构造一个新的 StringIndexOutOfBoundsException 类。

参数:

参数名称 参数描述
index 非法索引。

原创文章,作者:晴川运维,如若转载,请注明出处:https://baike.qcidc.com/11429.html

(0)
晴川运维晴川运维
上一篇 2025年7月3日
下一篇 2025年7月3日

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注