Home Java javaTutorial Explanation of Java classification exception issues

Explanation of Java classification exception issues

Jul 18, 2017 pm 05:50 PM
java Classification abnormal

Error: error, usually does not require programmer management, generally refers to insufficient memory, etc.
Exception: exception

According to the timing of running, it is divided into:
Runtime exception: RuntimeException: Exception that only occurs when running.
Non-runtime exceptions:

According to whether they are safe or not, they are divided into:
Checked exceptions: file opening exceptions, file operation exceptions, database operation exceptions, etc.
Unchecked exceptions: programmers are not careful To verify, the resulting exceptions include subscript out-of-bounds exceptions, null pointer exceptions, and type conversion exceptions.


Processing methods:
Two methods: keyword processing such as try
throw and throws keyword processing

Principle: The lower layer should throw exceptions , the surface layer is converted into business language to remind users.


Exception handling in projects should be user-specific.
Business exception: Abnormality that occurs in the business.

Customized exception: encapsulates business exceptions as well as the location and cause of the exception.

Java Exception:

1、Error
2、Runtime Exception Runtime exception
3、Exception
4、throw user-defined exception

The exception class is divided into two types: the Error class represents compilation and system errors and does not allow capture; the Exception class represents exceptions triggered by standard Java library methods. The Exception class also contains two direct subclasses: Runtime_Exception and Non_RuntimeException.

The running exception class corresponds to compilation errors, which refers to various exceptions generated by the interpreter when a Java program is running. Running exceptions may appear anywhere and occur very frequently, so in order to avoid huge system resource overhead, the compiler does not check for exceptions. Therefore, runtime exceptions in the Java language may not necessarily be caught. Operation errors often indicate errors in the code, such as arithmetic exceptions (such as division by 0), subscript exceptions (such as array out-of-bounds), etc.

Non-running exceptions are instances of the Non_RuntimeException class and its subclasses, also known as detectable exceptions. The Java compiler uses the possible results in the analysis method or construction method to detect whether the Java program contains a handler for detecting exceptions. For each possible detectable exception, the throws clause of the method or construction method must list the exception corresponding the type. The exceptions defined in Java's standard packages java.lang java.util and java.net are non-running exceptions.

Arithmetic exception class: ArithmeticExecption

Null pointer exception class: NullPointerException

Type cast exception: ClassCastException

Array negative Standard exception: NegativeArrayException

Array subscript out-of-bounds exception: ArrayIndexOutOfBoundsException

Violation of security principles exception: SecurityException

File has ended Exception: EOFException

File not found Exception: FileNotFoundException

String to number conversion exception: NumberFormatException


Operation database exception: SQLException


Input and output exception: IOException


Method not found exception: NoSuchMethodException

java.lang.AbstractMethodError

Abstract method error. Thrown when the application attempts to call an abstract method.

java.lang.AssertionError

Assertion error. Used to indicate an assertion failure.

java.lang.ClassCircularityError

Class circular dependency error. When initializing a class, this exception is thrown if a circular dependency between classes is detected.

java.lang.ClassFormatError

Class format error. Thrown when the Java virtual machine attempts to read a Java class from a file and detects that the contents of the file do not conform to a valid format for the class.

java.lang.Error

Error. Is the base class for all errors and is used to identify serious program operation problems. These problems usually describe some unusual situation that should not be caught by the application.

java.lang.ExceptionInInitializerError

Initializer error. Thrown when an exception occurs during the execution of a class's static initializer. Static initializer refers to the static statement segment directly included in the class.

java.lang.IllegalAccessError

Illegal access error. This exception is thrown when an application attempts to access or modify a field of a class or call its method, but violates the visibility declaration of the field or method.

java.lang.IncompatibleClassChangeError

Incompatible class change error. This exception is thrown when an incompatible change occurs in the class definition on which the method being executed depends. Generally, this error is easily caused when the declaration definition of some classes in the application is modified without recompiling the entire application and then running it directly.

java.lang.InstantiationError

Instantiation error. This exception is thrown when an application attempts to construct an abstract class or interface through Java's new operator.

java.lang.InternalError

Internal error. Used to indicate that an internal error has occurred in the Java virtual machine.

java.lang.LinkageError

Linkage error. This error and all its subclasses indicate that a class depends on other classes. After the class is compiled, the dependent class changes its class definition without recompiling all classes, thus causing the error condition.

java.lang.NoClassDefFoundError

Class definition not found error. This error is thrown when the Java virtual machine or class loader attempts to instantiate a class and cannot find the definition of the class.

java.lang.NoSuchFieldError

Field does not exist error. This error is thrown when an application attempts to access or modify a field of a class that does not have a definition for that field.

java.lang.NoSuchMethodError

There is no error in the method. This error is thrown when the application attempts to call a method of a class that does not have a definition for the method.

java.lang.OutOfMemoryError

Out of memory error. This error is thrown when the available memory is insufficient for the Java virtual machine to allocate an object.

java.lang.StackOverflowError

Stack overflow error. This error is thrown when an application makes too many recursive calls and causes a stack overflow.

java.lang.ThreadDeath

The thread ends. This error is thrown when the stop method of the Thread class is called to indicate the end of the thread.

java.lang.UnknownError

Unknown error. Used to indicate that an unknown serious error has occurred in the Java virtual machine.

java.lang.UnsatisfiedLinkError

Unsatisfied link error. Thrown when the Java virtual machine does not find a native language definition of a class that declares a native method.

java.lang.UnsupportedClassVersionError

Unsupported class version error. This error is thrown when the Java virtual machine tries to read a certain class file, but finds that the major and minor version numbers of the file are not supported by the current Java virtual machine.

java.lang.VerifyError

Verification error. This error is thrown when the validator detects an internal incompatibility or security issue in a class file.

java.lang.VirtualMachineError

Virtual machine error. Used to indicate a situation where a virtual machine has been destroyed or has insufficient resources to continue operations.


java.lang.ArithmeticException

Arithmetic condition exception. For example: integer division by zero, etc.

java.lang.ArrayIndexOutOfBoundsException

Array index out-of-bounds exception. Thrown when the index into the array is negative or greater than or equal to the array size.

java.lang.ArrayStoreException

Array storage exception. Thrown when an object of non-array declared type is stored in an array.

java.lang.ClassCastException

Class cast exception. Suppose there are classes A and B (A is not the parent class or subclass of B), and O is an instance of A, then this exception is thrown when O is forced to be constructed as an instance of class B. This exception is often called a cast exception.

java.lang.ClassNotFoundException

Cannot find class exception. This exception is thrown when the application attempts to construct a class based on a class name in string form, but cannot find the class file with the corresponding name after traversing the CLASSPAH.

java.lang.CloneNotSupportedException

Clone exception is not supported. When the Cloneable interface is not implemented or the clone method is not supported, calling its clone() method will throw this exception.

java.lang.EnumConstantNotPresentException

There is no exception in the enumeration constant. This exception is thrown when an application attempts to access an enumeration object by name and enumeration type, but the enumeration object does not contain a constant.

java.lang.Exception

Root exception. Used to describe the situation the application wishes to capture.

java.lang.IllegalAccessException

Illegal access exception. This exception is thrown when the application attempts to create an instance of a class, access the class properties, or call the class method through reflection, and the definition of the class, attribute, method, or constructor cannot be accessed at that time.

java.lang.IllegalMonitorStateException

Illegal monitoring state exception. This exception is thrown when a thread attempts to wait for the monitor of an object (O) that it does not own or notifies other threads to wait for the monitor of the object (O).

java.lang.IllegalStateException

Illegal state exception. This exception is thrown when a method is called in the Java environment and application before it is in a legal calling state.

java.lang.IllegalThreadStateException

Illegal thread state exception. When the county is not in the legal calling state of a certain method and the method is called, an exception is thrown.

java.lang.IndexOutOfBoundsException

Index out-of-bounds exception. This exception is thrown when the index value of a sequence is less than 0 or greater than or equal to the sequence size.

java.lang.InstantiationException

Instantiation exception. This exception is thrown when trying to create an instance of a class through the newInstance() method, and the class is an abstract class or interface.

java.lang.InterruptedException

Interrupted exception. This exception is thrown when a thread is waiting, sleeping or otherwise suspended for a long time, and other threads terminate the thread through Thread's interrupt method.

java.lang.NegativeArraySizeException

The array size is a negative exception. This exception is thrown when an array is created with a negative size value.

java.lang.NoSuchFieldException

There is no exception in the property. This exception is thrown when accessing a non-existent property of a class.

java.lang.NoSuchMethodException

There is no exception in the method. This exception is thrown when accessing a non-existent method of a class.

java.lang.NullPointerException

Null pointer exception. This exception is thrown when the application attempts to use null where an object is required. For example: calling the instance method of the null object, accessing the properties of the null object, calculating the length of the null object, using the throw statement to throw null, etc.

java.lang.NumberFormatException

Number format exception. This exception is thrown when an attempt is made to convert a String to a specified numeric type and the string does not meet the format required by the numeric type.

java.lang.RuntimeException

Runtime exception. Is the parent class for all exceptions that can be thrown during normal operation of the Java virtual machine.

java.lang.SecurityException

Security exception. An exception thrown by the security manager to indicate a security violation.

java.lang.StringIndexOutOfBoundsException

String index out-of-bounds exception. This exception is thrown when a character in a string is accessed using an index value that is less than 0 or greater than or equal to the sequence size.

java.lang.TypeNotPresentException

The type does not exist. This exception is thrown when an application attempts to access a type as a string representation of the type name, but the type cannot be found based on the given name. The difference between this exception and ClassNotFoundException is that this exception is an unchecked (unchecked) exception, while ClassNotFoundException is a checked (checked) exception.

java.lang.UnsupportedOperationException

Unsupported method exception. Exception indicating that the requested method is not supported.

Exception
javax.servlet.jsp.JspException: Cannot retrieve mapping for action /Login (/Login is your action name)

Possible reasons
action no longer struts- defined in config.xml, or no matching action is found, for example, use


The above is the detailed content of Explanation of Java classification exception issues. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Perfect Number in Java Perfect Number in Java Aug 30, 2024 pm 04:28 PM

Guide to Perfect Number in Java. Here we discuss the Definition, How to check Perfect number in Java?, examples with code implementation.

Weka in Java Weka in Java Aug 30, 2024 pm 04:28 PM

Guide to Weka in Java. Here we discuss the Introduction, how to use weka java, the type of platform, and advantages with examples.

Smith Number in Java Smith Number in Java Aug 30, 2024 pm 04:28 PM

Guide to Smith Number in Java. Here we discuss the Definition, How to check smith number in Java? example with code implementation.

Java Spring Interview Questions Java Spring Interview Questions Aug 30, 2024 pm 04:29 PM

In this article, we have kept the most asked Java Spring Interview Questions with their detailed answers. So that you can crack the interview.

Break or return from Java 8 stream forEach? Break or return from Java 8 stream forEach? Feb 07, 2025 pm 12:09 PM

Java 8 introduces the Stream API, providing a powerful and expressive way to process data collections. However, a common question when using Stream is: How to break or return from a forEach operation? Traditional loops allow for early interruption or return, but Stream's forEach method does not directly support this method. This article will explain the reasons and explore alternative methods for implementing premature termination in Stream processing systems. Further reading: Java Stream API improvements Understand Stream forEach The forEach method is a terminal operation that performs one operation on each element in the Stream. Its design intention is

TimeStamp to Date in Java TimeStamp to Date in Java Aug 30, 2024 pm 04:28 PM

Guide to TimeStamp to Date in Java. Here we also discuss the introduction and how to convert timestamp to date in java along with examples.

Java Program to Find the Volume of Capsule Java Program to Find the Volume of Capsule Feb 07, 2025 am 11:37 AM

Capsules are three-dimensional geometric figures, composed of a cylinder and a hemisphere at both ends. The volume of the capsule can be calculated by adding the volume of the cylinder and the volume of the hemisphere at both ends. This tutorial will discuss how to calculate the volume of a given capsule in Java using different methods. Capsule volume formula The formula for capsule volume is as follows: Capsule volume = Cylindrical volume Volume Two hemisphere volume in, r: The radius of the hemisphere. h: The height of the cylinder (excluding the hemisphere). Example 1 enter Radius = 5 units Height = 10 units Output Volume = 1570.8 cubic units explain Calculate volume using formula: Volume = π × r2 × h (4

Create the Future: Java Programming for Absolute Beginners Create the Future: Java Programming for Absolute Beginners Oct 13, 2024 pm 01:32 PM

Java is a popular programming language that can be learned by both beginners and experienced developers. This tutorial starts with basic concepts and progresses through advanced topics. After installing the Java Development Kit, you can practice programming by creating a simple "Hello, World!" program. After you understand the code, use the command prompt to compile and run the program, and "Hello, World!" will be output on the console. Learning Java starts your programming journey, and as your mastery deepens, you can create more complex applications.

See all articles