- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- All Implemented Interfaces:
-
Serializable
- 已知直接子类:
-
AbsentInformationException,AclNotFoundException,ActivationException,AgentInitializationException,AgentLoadException,AlreadyBoundException,ApplicationException,AttachNotSupportedException,AWTException,BackingStoreException,BadAttributeValueExpException,BadBinaryOpValueExpException,BadLocationException,BadStringOperationException,BrokenBarrierException,CardException,CertificateException,ClassNotLoadedException,CloneNotSupportedException,DataFormatException,DatatypeConfigurationException,DestroyFailedException,ExecutionControl.ExecutionControlException,ExecutionException,ExpandVetoException,FontFormatException,GeneralSecurityException,GSSException,IllegalClassFormatException,IllegalConnectorArgumentsException,IncompatibleThreadStateException,InterruptedException,IntrospectionException,InvalidApplicationException,InvalidMidiDataException,InvalidPreferencesFormatException,InvalidTargetObjectTypeException,InvalidTypeException,InvocationException,IOException,JAXBException,JMException,JShellException,KeySelectorException,LambdaConversionException,LastOwnerException,LineUnavailableException,MarshalException,MidiUnavailableException,MimeTypeParseException,MimeTypeParseException,NamingException,NoninvertibleTransformException,NonInvertibleTransformException,NotBoundException,NotOwnerExceptionNotOwnerException,ParseException,ParserConfigurationException,PrinterException,PrintException,PrivilegedActionException,PropertyVetoException,ReflectiveOperationException,RefreshFailedException,RemarshalException,RuntimeException,SAXException,ScriptException,ServerNotActiveException,SOAPException,SQLException,StringConcatException,TimeoutException,TooManyListenersException,TransformerException,TransformException,UnavailableServiceException,UnmodifiableClassException,UnsupportedAudioFileException,UnsupportedCallbackException,UnsupportedFlavorException,UnsupportedLookAndFeelException,URIReferenceException,URISyntaxException,UserException,VMStartException,XAException,XMLParseException,XMLSignatureException,XMLStreamException,XPathException
public class 异常 extends Throwable
异常及其子类是Throwable的形式,表示合理应用程序可能想要捕获的条件。异常类和不是RuntimeException的子类的任何子类都是检查异常 。 检查的异常需要在方法或构造函数的throws子句中声明,如果它们可以通过执行方法或构造函数抛出,并在方法或构造函数边界之外传播。- 从以下版本开始:
- 1.0
- 另请参见:
-
Error, Serialized Form - See The Java™ Language Specification:
- 11.2编译时检查异常
-
-
构造方法摘要
构造方法 Modifier Constructor 描述 异常()构造一个新的异常,以null作为其详细信息。异常(String message)使用指定的详细消息构造新的异常。异常(String message, Throwable cause)构造一个新的异常与指定的详细信息和原因。protected异常(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace)构造一个新的异常,指定的详细消息,启用或禁用抑制,启用或禁用可写栈跟踪。异常(Throwable cause)构造具有指定原因的新异常和详细消息为(cause==null ? null : cause.toString())(通常包含类和详细消息为cause)。
-
方法摘要
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
-
-
-
构造方法详细信息
-
异常
public Exception()
构造一个新的异常,以null作为其详细信息。 原因未初始化,并可能随后通过调用Throwable.initCause(java.lang.Throwable)进行初始化。
-
异常
public Exception(String message)
使用指定的详细消息构造新的异常。 原因未初始化,可以随后通过调用Throwable.initCause(java.lang.Throwable)进行初始化。- 参数
-
message- 详细信息。 保存详细信息以供稍后通过Throwable.getMessage()检索。
-
异常
public Exception(String message, Throwable cause)
构造一个新的异常与指定的详细信息和原因。请注意,与
cause相关联的详细信息不会自动并入此异常的详细消息。- 参数
-
message- 详细信息(保存以供Throwable.getMessage()方法稍后检索)。 -
cause- 原因(由Throwable.getCause()方法保存供以后检索)。 (Anull值是允许的,并且表示原因不存在或未知。) - 从以下版本开始:
- 1.4
-
异常
public Exception(Throwable cause)
构造具有指定原因的新异常和详细消息为(cause==null ? null : cause.toString())(通常包含类别和详细信息为cause)。 这个构造函数对于除了其他throwable的包装外的异常(例如,PrivilegedActionException) 很有用 。- 参数
-
cause- 原因(保存以供Throwable.getCause()方法稍后检索)。 (Anull值为null,表示原因不存在或未知。) - 从以下版本开始:
- 1.4
-
-