鸿蒙OS开发文档 第61页

鸿蒙OS NullPointerException

NullPointerException java.lang.Object |—java.lang.Throwable |—|—java.lang.Exception |—|—|—java.lang.RuntimeException |—|—|—|—java.lang.NullPointerException public class NullPointerException extends RuntimeException 当应用程序在需要对象的情况下尝试使用 null 时引发。 这些包括: 调用空对象的实例方法。 访问或修改空对象的字段。 将 null 的长度视为一个数组。 访问或修改 null 的槽,就像它是一个数组一样。 将 null 视为 Throwable 值。 应用程序应抛出此类的实例以指示空对象的其他非法使用。 NullPointerException 对象可以由虚拟机构造,就像 Throwable#Throwable(String, Throwable, boolean, boolean)。 构造函数摘要 构造函数 描述 NullPointerException() 构造一个没有详细消息的 NullPointerException。 NullPointerException(String s) 构造带有指定详细消息的 NullPointerException。 方法总结 从类 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 构造函数详细信息 NullPointerException public NullPointerException() 构造一个没有详细消息的 NullPointerException。 NullPointerException public NullPointerException(String s) 构造带有指定详细消息的 NullPointerException。 参数: 参数名称 参数描述 s 详细信息。

鸿蒙OS NoSuchMethodException

NoSuchMethodException java.lang.Object |—java.lang.Throwable |—|—java.lang.Exception |—|—|—java.lang.ReflectiveOperationException |—|—|—|—java.lang.NoSuchMethodException public class NoSuchMethodException extends ReflectiveOperationException 当找不到特定方法时抛出。 构造函数摘要 构造函数 描述 NoSuchMethodException() 构造一个没有详细消息的 NoSuchMethodException。 NoSuchMethodException(String s) 构造带有详细消息的 NoSuchMethodException。 方法总结 从类 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 构造函数详细信息 NoSuchMethodException public NoSuchMethodException() 构造一个没有详细消息的 NoSuchMethodException。 NoSuchMethodException public NoSuchMethodException(String s) 构造带有详细消息的 NoSuchMethodException。 参数: 参数名称 参数描述 s 详细信息。

鸿蒙OS NoSuchFieldException

NoSuchFieldException java.lang.Object |—java.lang.Throwable |—|—java.lang.Exception |—|—|—java.lang.ReflectiveOperationException |—|—|—|—java.lang.NoSuchFieldException public class NoSuchFieldException extends ReflectiveOperationException 表示该类没有指定名称的字段。 构造函数摘要 构造函数 描述 NoSuchFieldException() 构造函数。 NoSuchFieldException(String s) 带有详细消息的构造函数。 方法总结 从类 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 构造函数详细信息 NoSuchFieldException public NoSuchFieldException() 构造函数。 NoSuchFieldException public NoSuchFieldException(String s) 带有详细消息的构造函数。 参数: 参数名称 参数描述 s 详细信息

鸿蒙OS NegativeArraySizeException

NegativeArraySizeException java.lang.Object |—java.lang.Throwable |—|—java.lang.Exception |—|—|—java.lang.RuntimeException |—|—|—|—java.lang.NegativeArraySizeException public class NegativeArraySizeException extends RuntimeException 如果应用程序尝试创建具有负大小的数组,则抛出此异常。 构造函数摘要 构造函数 描述 NegativeArraySizeException() 构造一个没有详细消息的 NegativeArraySizeException。 NegativeArraySizeException(String s) 构造带有指定详细消息的 NegativeArraySizeException。 方法总结 从类 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 构造函数详细信息 NegativeArraySizeException public NegativeArraySizeException() 构造一个没有详细消息的 NegativeArraySizeException。 NegativeArraySizeException public NegativeArraySizeException(String s) 构造带有指定详细消息的 NegativeArraySizeException。 参数: 参数名称 参数描述 s 详细信息。

鸿蒙OS InterruptedException

InterruptedException java.lang.Object |—java.lang.Throwable |—|—java.lang.Exception |—|—|—java.lang.InterruptedException public class InterruptedException extends Exception 当线程等待、休眠或以其他方式被占用,并且线程在活动之前或期间被中断时抛出。 有时某个方法可能希望测试当前线程是否已被中断,如果是,则立即抛出此异常。 下面的代码可以用来实现这个效果: if (Thread.interrupted()) // Clears interrupted status! throw new InterruptedException(); 构造函数摘要 构造函数 描述 InterruptedException() 构造一个没有详细消息的 InterruptedException。 InterruptedException(String s) 构造带有指定详细消息的 InterruptedException。 方法总结 从类 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 构造函数详细信息 InterruptedException public InterruptedException() 构造一个没有详细消息的 InterruptedException。 InterruptedException public InterruptedException(String s) 构造带有指定详细消息的 InterruptedException。 参数: 参数名称 参数描述 s 详细信息。

鸿蒙OS InstantiationException

InstantiationException java.lang.Object |—java.lang.Throwable |—|—java.lang.Exception |—|—|—java.lang.ReflectiveOperationException |—|—|—|—java.lang.InstantiationException public class InstantiationException extends ReflectiveOperationException 当应用程序尝试使用类 Class 中的 newInstance 方法创建类的实例,但无法实例化指定的类对象时抛出。 实例化可能由于多种原因而失败,包括但不限于: 类对象表示抽象类、接口、数组类、原始类型或 void 该类没有空构造函数 构造函数摘要 构造函数 描述 InstantiationException() 构造一个没有详细消息的 InstantiationException。 InstantiationException(String s) 使用指定的详细消息构造一个 InstantiationException。 方法总结 从类 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 构造函数详细信息 InstantiationException public InstantiationException() 构造一个没有详细消息的 InstantiationException。 InstantiationException public InstantiationException(String s) 使用指定的详细消息构造一个 InstantiationException。 参数: 参数名称 参数描述 s 详细信息。

鸿蒙OS IndexOutOfBoundsException

IndexOutOfBoundsException java.lang.Object |—java.lang.Throwable |—|—java.lang.Exception |—|—|—java.lang.RuntimeException |—|—|—|—java.lang.IndexOutOfBoundsException public class IndexOutOfBoundsException extends RuntimeException 抛出以指示某种索引(例如数组、字符串或向量)超出范围。 应用程序可以对此类进行子类化以指示类似的异常。 构造函数摘要 构造函数 描述 IndexOutOfBoundsException() 构造一个没有详细消息的 IndexOutOfBoundsException。 IndexOutOfBoundsException(String s) 使用指定的详细消息构造 IndexOutOfBoundsException。 方法总结 从类 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 构造函数详细信息 IndexOutOfBoundsException public IndexOutOfBoundsException() 构造一个没有详细消息的 IndexOutOfBoundsException。 IndexOutOfBoundsException public IndexOutOfBoundsException(String s) 使用指定的详细消息构造 IndexOutOfBoundsException。 参数: 参数名称 参数描述 s 详细信息。

鸿蒙OS IllegalThreadStateException

IllegalThreadStateException java.lang.Object |—java.lang.Throwable |—|—java.lang.Exception |—|—|—java.lang.RuntimeException |—|—|—|—java.lang.IllegalArgumentException |—|—|—|—|—java.lang.IllegalThreadStateException public class IllegalThreadStateException extends IllegalArgumentException 抛出以指示线程未处于请求操作的适当状态。 例如,参见类 Thread 中的暂停和恢复方法。 构造函数摘要 构造函数 描述 IllegalThreadStateException() 构造一个没有详细消息的 IllegalThreadStateException。 IllegalThreadStateException(String s) 构造带有指定详细消息的 IllegalThreadStateException。 方法总结 从类 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 构造函数详细信息 IllegalThreadStateException public IllegalThreadStateException() 构造一个没有详细消息的 IllegalThreadStateException。 IllegalThreadStateException public IllegalThreadStateException(String s) 构造带有指定详细消息的 IllegalThreadStateException。 参数: 参数名称 参数描述 s 详细信息。

鸿蒙OS IllegalStateException

IllegalStateException java.lang.Object |—java.lang.Throwable |—|—java.lang.Exception |—|—|—java.lang.RuntimeException |—|—|—|—java.lang.IllegalStateException public class IllegalStateException extends RuntimeException 表示方法已在非法或不适当的时间被调用。 换言之,Java 环境或 Java 应用程序未处于请求操作的适当状态。 构造函数摘要 构造函数 描述 IllegalStateException() 构造一个不带详细消息的 IllegalStateException。 IllegalStateException(String s) 构造带有指定详细消息的 IllegalStateException。 IllegalStateException(String message, Throwable cause) 使用指定的详细消息和原因构造一个新异常。 IllegalStateException(Throwable cause) 构造一个具有指定原因的新异常和 (cause==null ? null : cause.toString()) 的详细消息(通常包含原因的类和详细消息)。 方法总结 从类 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 构造函数详细信息 IllegalStateException public IllegalStateException() 构造一个不带详细消息的 IllegalStateException。 详细消息是描述此特定异常的字符串。 IllegalStateException public IllegalStateException(String s) 构造带有指定详细消息的 IllegalStateException。 详细消息是描述此特定异常的字符串。 参数: 参数名称 参数描述 s 包含详细消息的字符串 IllegalStateException public IllegalStateException(String message, Throwable cause) 使用指定的详细消息和原因构造一个新异常。 请注意,与原因相关的详细消息不会自动合并到此异常的详细消息中。 参数: 参数名称 参数描述 message 详细消息(保存以供 Throwable#getMessage() 方法稍后检索)。 cause 原因(由 Throwable#getCause() 方法保存以供以后检索)。 (允许使用空值,表示原因不存在或未知。) IllegalStateException public IllegalStateException(Throwable cause) 构造一个具有指定原因的新异常和 (cause==null ? null : cause.toString()) 的详细消息(通常包含原因的类和详细消息)。 此构造函数对于仅是其他 throwable 的包装器(例如 PrivilegedActionException)的异常非常有用。 参数: 参数名称 参数描述 cause 原因(由 Throwable#getCause() 方法保存以供以后检索)。 (允许使用空值,表示原因不存在或未知。)

鸿蒙OS IllegalMonitorStateException

IllegalMonitorStateException java.lang.Object |—java.lang.Throwable |—|—java.lang.Exception |—|—|—java.lang.RuntimeException |—|—|—|—java.lang.IllegalMonitorStateException public class IllegalMonitorStateException extends RuntimeException 抛出以指示线程已尝试在对象的监视器上等待,或通知其他线程在对象的监视器上等待而不拥有指定的监视器。 构造函数摘要 构造函数 描述 IllegalMonitorStateException() 构造一个不带详细消息的 IllegalMonitorStateException。 IllegalMonitorStateException(String s) 构造带有指定详细消息的 IllegalMonitorStateException。 方法总结 从类 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 构造函数详细信息 IllegalMonitorStateException public IllegalMonitorStateException() 构造一个不带详细消息的 IllegalMonitorStateException。 IllegalMonitorStateException public IllegalMonitorStateException(String s) 构造带有指定详细消息的 IllegalMonitorStateException。 参数: 参数名称 参数描述 s 详细信息。