Summary of java exceptions and error classes
Recently, due to the examination and previous interviews, I often encountered problems with the inheritance level of exception classes in Java, which made me very troublesome because there are a lot of exceptions in Java and it is difficult to write them down. Today I happened to check some information and sort them out. I hope it will be helpful to myself and everyone. At the beginning, I was used to taking notes with a notebook (handwritten paper notebook). Later I found that it was not very convenient to check and the speed was relatively slow. Later, I switched to notepad to start recording. It felt very effective, simple and easy to use, and there were no fancy things. However, it also has its shortcomings, such as the layout sorting, the inability to add some pictures (often pictures, especially some outlines, are very good memory learning methods), etc. So try to start writing with markdown, put them on the blog and read them easily, and let everyone share and learn and make progress together. Since I started learning computer-related fields until now, I am very grateful to many domestic and foreign giants for their selfless sharing. I have really learned a lot. While I continue to learn knowledge in the future, I encourage myself and write more things to share with you. Welcome to point out the shortcomings and mistakes and learn together.
1. The main classes of java exceptions and errors
Java exceptions are divided into exceptions and errors, Exception and Error, two classes. Both classes are inherited from the Throwable class, and Throwable is the root of all Java exceptions.
All exception classes in Java include Throwable, Exception, and Error, which are all classes, so they can be instantiated (you often encounter them in written tests)
Error: cannot be handled reasonably by program
The machine has insufficient memory
JVM crashes (the program may hang up)
The thread hangs up...
Exception: can be handled by program
IO error (keyboard, disk)
Network error
Illegal type conversion
Arrays or containers cross boundaries
Java exceptions are generally divided into runtime exceptions and non-runtime exceptions
Runtime exceptions are all subclasses of RunTimeException
Non-runtime exceptions are all other child classes of Exception, such as IOException, InterruptedException
2. Java exception structure diagram
3. Java exception-detailed class hierarchy
All exceptions in the java.lang package
java.lang.Throwable (implements java.io.Serializable)
java.lang.Error
java.lang.AssertionError
java.lang.LinkageError
java.lang.BootstrapMethodError
java.lang.ClassCircularityError
java.lang.ClassFormatError
java.lang.UnsupportedClassVersionError
java.lang.ExceptionInInitializerError
java.lang.IncompatibleClassChangeError
java.lang.AbstractMethodError
java.lang.IllegalAccessError
java.lang.InstantiationError
java.lang.NoSuchFieldError
java.lang.NoSuchMethodError
java.lang.NoClassDefFoundError
java.lang.UnsatisfiedLinkError
java.lang.VerifyError
java.lang.ThreadDeath
java.lang.VirtualMachineError
java.lang.InternalError
java.lang.OutOfMemoryError
java.lang.StackOverflowError
java.lang.UnknownError
java.lang.Exception
java.lang.CloneNotSupportedException
java.lang.InterruptedException
java.lang.ReflectiveOperationException
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.lang.NoSuchFieldException
java.lang.NoSuchMethodException
java.lang.RuntimeException
java.lang.ArithmeticException
java.lang.ArrayStoreException
java.lang.ClassCastException
java.lang.EnumConstantNotPresentException
java.lang.IllegalArgumentException
java.lang.IllegalThreadStateException
java.lang.NumberFormatException
java.lang.IllegalMonitorStateException
java.lang.IllegalStateException
java.lang.IndexOutOfBoundsException
java.lang.ArrayIndexOutOfBoundsException
java.lang.StringIndexOutOfBoundsException
java.lang.NegativeArraySizeException
java.lang.NullPointerException
java.lang.SecurityException
java.lang.TypeNotPresentException
java.lang.UnsupportedOperationException
All IO exceptions in the java.io package
ava.lang.Exception
java.io.IOException
java.io.CharConversionException
java.io.EOFException
java.io.FileNotFoundException
java.io.InterruptedIOException
java.io.ObjectStreamException
java.io.InvalidClassException
java.io.InvalidObjectException
java.io.NotActiveException
java.io.NotSerializableException
java.io.OptionalDataException
java.io.StreamCorruptedException
java.io.WriteAbortedException
java.io.SyncFailedException
java.io.UnsupportedEncodingException
java.io.UTFDataFormatException
The above summary of java exceptions and errors (must-read) is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.