标签:其他 odex normal min nat pac dac 垃圾回收 子类
try {
throw new RuntimeException();
} catch (ArithmeticException e) {
e.printStackTrace();
} catch (RuntimeException e) {
System.out.println("==============只执行此catch语句,而不会再匹配或执行下面的catch字句============");
e.printStackTrace();
System.exit(0);
} catch (Exception e) {
e.printStackTrace();
} catch (Throwable th) {
th.printStackTrace();
} finally {
System.out.println("编译通过,但是因为之前执行了System.exit(0),所以执行不到");
}
System.out.println("编译通过,同样因为之前执行了System.exit(0),所以执行不到");
try {
throw new RuntimeException();
} catch (ArithmeticException e) {
e.printStackTrace();
} catch (RuntimeException e) {
System.out.println("==============只执行此catch语句,而不会再匹配或执行下面的catch字句============");
e.printStackTrace();
System.exit(0);
} catch (Exception e) {
e.printStackTrace();
} catch (Throwable th) {
th.printStackTrace();
} finally {
System.out.println("编译通过,但是因为之前执行了System.exit(0),所以执行不到");
}
System.out.println("编译通过,同样因为之前执行了System.exit(0),所以执行不到");
class Fu {
protected void test() throws ArithmeticException, BufferOverflowException {
}
}
class Zi extends Fu {
@Override
protected void test() throws ArithmeticException {
}
}
class Fu {
protected void test() throws ArithmeticException, BufferOverflowException {
}
}
class Zi extends Fu {
protected void test() throws ArithmeticException {
}
}
throw new RuntimeException();
System.out.println("编译失败");//编译失败,因为 throw 语句后面的代码是执行不到的
throw new RuntimeException();
System.out.println("编译失败");//编译失败,因为 throw 语句后面的代码是执行不到的
try {
throw new RuntimeException();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("编译通过"); //try catch 语句后面的语句是可以正常执行的
try {
throw new RuntimeException();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("编译通过"); //try catch 语句后面的语句是可以正常执行的
继承自:Object
实现的接口:Serializable
直接已知子类:Error, Exception
继承自:Object
实现的接口:Serializable
直接已知子类:Error, Exception
public class Test {
public static void main(String[] args) {
Throwable throwable = new Throwable("你好", new Exception("一个cause"));
System.out.println(throwable.getMessage() + " " + throwable.getCause());//你好 java.lang.Exception: 一个cause
System.out.println("-----------------------------------------");
throwable.printStackTrace();
throwable.fillInStackTrace();
System.out.println("-----------------------------------------");
throwable.printStackTrace();
}
}
public class Test {
public static void main(String[] args) {
Throwable throwable = new Throwable("你好", new Exception("一个cause"));
System.out.println(throwable.getMessage() + " " + throwable.getCause());//你好 java.lang.Exception: 一个cause
System.out.println("-----------------------------------------");
throwable.printStackTrace();
throwable.fillInStackTrace();
System.out.println("-----------------------------------------");
throwable.printStackTrace();
}
}
你好 java.lang.Exception: 一个cause
-----------------------------------------
java.lang.Throwable: 你好
at Test.main(Test.java:3)
Caused by: java.lang.Exception: 一个cause
... 1 more
-----------------------------------------
java.lang.Throwable: 你好
at Test.main(Test.java:7)
Caused by: java.lang.Exception: 一个cause
at Test.main(Test.java:3)
你好 java.lang.Exception: 一个cause
-----------------------------------------
java.lang.Throwable: 你好
at Test.main(Test.java:3)
Caused by: java.lang.Exception: 一个cause
... 1 more
-----------------------------------------
java.lang.Throwable: 你好
at Test.main(Test.java:7)
Caused by: java.lang.Exception: 一个cause
at Test.main(Test.java:3)
Exception in thread "main" java.lang.NullPointerException
at Test.mash(Test.java:11)
at Test.crunch(Test.java:7)
at Test.main(Test.java:3)
Exception in thread "main" java.lang.NullPointerException
at Test.mash(Test.java:11)
at Test.crunch(Test.java:7)
at Test.main(Test.java:3)
public class Test {
public static void main(String[] args) {
crunch(null);
}
static void crunch(int[] a) {
mash(a);
}
static void mash(int[] b) {
System.out.println(b[0]);
}
}
public class Test {
public static void main(String[] args) {
crunch(null);
}
static void crunch(int[] a) {
mash(a);
}
static void mash(int[] b) {
System.out.println(b[0]);
}
}
HighLevelException: MidLevelException: LowLevelException
at Test.a(Test.java:14)
at Test.main(Test.java:4)
Caused by: MidLevelException: LowLevelException
at Test.c(Test.java:26)
at Test.b(Test.java:19)
at Test.a(Test.java:12)
... 1 more
Caused by: LowLevelException
at Test.e(Test.java:35)
at Test.d(Test.java:31)
at Test.c(Test.java:24)
... 3 more
HighLevelException: MidLevelException: LowLevelException
at Test.a(Test.java:14)
at Test.main(Test.java:4)
Caused by: MidLevelException: LowLevelException
at Test.c(Test.java:26)
at Test.b(Test.java:19)
at Test.a(Test.java:12)
... 1 more
Caused by: LowLevelException
at Test.e(Test.java:35)
at Test.d(Test.java:31)
at Test.c(Test.java:24)
... 3 more
public class Test {
public static void main(String args[]) {
try {
a();
} catch (HighLevelException e) {
e.printStackTrace();
}
}
static void a() throws HighLevelException {
try {
b();
} catch (MidLevelException e) {
throw new HighLevelException(e);
}
}
static void b() throws MidLevelException {
c();
}
static void c() throws MidLevelException {
try {
d();
} catch (LowLevelException e) {
throw new MidLevelException(e);
}
}
static void d() throws LowLevelException {
e();
}
static void e() throws LowLevelException {
throw new LowLevelException();
}
}
public class Test {
public static void main(String args[]) {
try {
a();
} catch (HighLevelException e) {
e.printStackTrace();
}
}
static void a() throws HighLevelException {
try {
b();
} catch (MidLevelException e) {
throw new HighLevelException(e);
}
}
static void b() throws MidLevelException {
c();
}
static void c() throws MidLevelException {
try {
d();
} catch (LowLevelException e) {
throw new MidLevelException(e);
}
}
static void d() throws LowLevelException {
e();
}
static void e() throws LowLevelException {
throw new LowLevelException();
}
}
class HighLevelException extends Exception {
HighLevelException(Throwable cause) {
super(cause);
}
}
class MidLevelException extends Exception {
MidLevelException(Throwable cause) {
super(cause);
}
}
class LowLevelException extends Exception {
}
class HighLevelException extends Exception {
HighLevelException(Throwable cause) {
super(cause);
}
}
class MidLevelException extends Exception {
MidLevelException(Throwable cause) {
super(cause);
}
}
class LowLevelException extends Exception {
}
AclNotFoundException, ActivationException, AlreadyBoundException, ApplicationException, AWTException, BackingStoreException, BadAttributeValueExpException, BadBinaryOpValueExpException, BadLocationException, BadStringOperationException, BrokenBarrierException, CertificateException, ClassNotFoundException, CloneNotSupportedException, DataFormatException, DatatypeConfigurationException, DestroyFailedException, ExecutionException, ExpandVetoException, FontFormatException, GeneralSecurityException, GSSException, IllegalAccessException, IllegalClassFormatException, InstantiationException, InterruptedException, IntrospectionException, InvalidApplicationException, InvalidMidiDataException, InvalidPreferencesFormatException, InvalidTargetObjectTypeException, InvocationTargetException, IOException, JAXBException, JMException, KeySelectorException, LastOwnerException, LineUnavailableException, MarshalException, MidiUnavailableException, MimeTypeParseException, MimeTypeParseException, NamingException, NoninvertibleTransformException, NoSuchFieldException, NoSuchMethodException, NotBoundException, NotOwnerException, ParseException, ParserConfigurationException, PrinterException, PrintException, PrivilegedActionException, PropertyVetoException, RefreshFailedException, RemarshalException, RuntimeException, SAXException, ScriptException, ServerNotActiveException, SOAPException, SQLException, TimeoutException, TooManyListenersException, TransformerException, TransformException, UnmodifiableClassException, UnsupportedAudioFileException, UnsupportedCallbackException, UnsupportedFlavorException, UnsupportedLookAndFeelException, URIReferenceException, URISyntaxException, UserException, XAException, XMLParseException, XMLSignatureException, XMLStreamException, XPathException
AclNotFoundException, ActivationException, AlreadyBoundException, ApplicationException, AWTException, BackingStoreException, BadAttributeValueExpException, BadBinaryOpValueExpException, BadLocationException, BadStringOperationException, BrokenBarrierException, CertificateException, ClassNotFoundException, CloneNotSupportedException, DataFormatException, DatatypeConfigurationException, DestroyFailedException, ExecutionException, ExpandVetoException, FontFormatException, GeneralSecurityException, GSSException, IllegalAccessException, IllegalClassFormatException, InstantiationException, InterruptedException, IntrospectionException, InvalidApplicationException, InvalidMidiDataException, InvalidPreferencesFormatException, InvalidTargetObjectTypeException, InvocationTargetException, IOException, JAXBException, JMException, KeySelectorException, LastOwnerException, LineUnavailableException, MarshalException, MidiUnavailableException, MimeTypeParseException, MimeTypeParseException, NamingException, NoninvertibleTransformException, NoSuchFieldException, NoSuchMethodException, NotBoundException, NotOwnerException, ParseException, ParserConfigurationException, PrinterException, PrintException, PrivilegedActionException, PropertyVetoException, RefreshFailedException, RemarshalException, RuntimeException, SAXException, ScriptException, ServerNotActiveException, SOAPException, SQLException, TimeoutException, TooManyListenersException, TransformerException, TransformException, UnmodifiableClassException, UnsupportedAudioFileException, UnsupportedCallbackException, UnsupportedFlavorException, UnsupportedLookAndFeelException, URIReferenceException, URISyntaxException, UserException, XAException, XMLParseException, XMLSignatureException, XMLStreamException, XPathException
AnnotationTypeMismatchException
ArithmeticException
ArrayStoreException
BufferOverflowException
BufferUnderflowException
CannotRedoException
CannotUndoException
ClassCastException
CMMException
ConcurrentModificationException
DOMException
EmptyStackException
EnumConstantNotPresentException
EventException
IllegalArgumentException
IllegalMonitorStateException
IllegalPathStateException
IllegalStateException
ImagingOpException
IncompleteAnnotationException
IndexOutOfBoundsException
JMRuntimeException
LSException
MalformedParameterizedTypeException
MirroredTypeException
MirroredTypesException
MissingResourceException
NegativeArraySizeException
NoSuchElementException
NoSuchMechanismException
NullPointerException
ProfileDataException
ProviderException
RasterFormatException
RejectedExecutionException
SecurityException
SystemException
TypeConstraintException
TypeNotPresentException
UndeclaredThrowableException
UnknownAnnotationValueException
UnknownElementException
UnknownTypeException
UnmodifiableSetException
UnsupportedOperationException
WebServiceException
AnnotationTypeMismatchException
ArithmeticException
ArrayStoreException
BufferOverflowException
BufferUnderflowException
CannotRedoException
CannotUndoException
ClassCastException
CMMException
ConcurrentModificationException
DOMException
EmptyStackException
EnumConstantNotPresentException
EventException
IllegalArgumentException
IllegalMonitorStateException
IllegalPathStateException
IllegalStateException
ImagingOpException
IncompleteAnnotationException
IndexOutOfBoundsException
JMRuntimeException
LSException
MalformedParameterizedTypeException
MirroredTypeException
MirroredTypesException
MissingResourceException
NegativeArraySizeException
NoSuchElementException
NoSuchMechanismException
NullPointerException
ProfileDataException
ProviderException
RasterFormatException
RejectedExecutionException
SecurityException
SystemException
TypeConstraintException
TypeNotPresentException
UndeclaredThrowableException
UnknownAnnotationValueException
UnknownElementException
UnknownTypeException
UnmodifiableSetException
UnsupportedOperationException
WebServiceException
异常 Throwable Exception Error 基础
标签:其他 odex normal min nat pac dac 垃圾回收 子类
原文地址:https://www.cnblogs.com/baiqiantao/p/9159435.html