Summary of common exceptions in Java

Source: Internet
Author: User
Tags arithmetic connection reset

1, Java.lang.ArithmeticException

An arithmetic operation exception, such as a divisor of 0, that throws an arithmetic exception

2, Java.lang.StringIndexOutOfBoundsException:

This is the subscript out-of-bounds exception resulting from the truncated string substring (). The reason may be that the string is empty, or the length is less than 1

3. Java.lang.NullPointerException NULL pointer exception

The exception occurs because a reference is NULL, but one of its methods is called.

4, ClassCastException

Type cast exception, for example: String str = "a"; Integer num = (integer) str;

5, IllegalArgumentException

Pass an illegal parameter exception, which indicates that an invalid or incorrect parameter was passed to the method. You see if the value method is incorrect

6, NumberFormatException

Numeric format exception, for example: String str = "a"; Integer.parseint (str);

7, ClientAbortException:java.io.IOException Abnormal

The reason is that because the server is processing an HTTP request, the user closes the browser when the content is being output, causing the clientabortexception exception. It is one of the more common types of I/O anomalies.

8, java.lang.ClassNotFoundException

  This anomaly is a lot of developers in the development environment originally developed in JB, and put the package under the JB under the WTK to compile the frequently occurring problem, the explanation of the exception is "The specified class does not exist", here mainly consider the name and path of the class is correct,
If the package is done under JB, it is usually the default plus packages, so go to the WTK and pay attention to add the path to package.

9. Clientabortexception caused by:java.NET.SocketException:Connection reset by Peer:socket write error

This exception is common and usually has the following conditions:

The number of concurrent connections to the server exceeds its capacity, and the server will drop some of the connections, the client shuts down the browser, and the server sends the data to the client.

10. Arraystoreexception

Holds an object exception that is incompatible with the declared type in the array, for example: Object x[] = new String[3];x[0] = new Integer (0);

One, negativearraysizeexception

Create an array error exception with a negative size, for example int[] arr = new Int[10];int i = arr[-1];

12, SecurityException

Security exceptions, such as: Android permissions exception, program prompts to run Java missing requited Permissions manifest attribute in main jar, etc.

13, Eofexception

File has ended exception

14. FileNotFoundException

File not found exception

15. SQLException

Manipulating Database Exceptions

16. nosuchmethodexception

Method not found exception

17. java.lang.ArrayIndexOutOfBoundsException

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

18. java.lang.IllegalAccessException

An illegal access exception. This exception is thrown when an application attempts to create an instance of a class by reflection, accesses the class property, calls the class method, and then cannot access the definition of a class, property, method, or constructor method.

19. java.lang.IllegalMonitorStateException

Violations of the monitoring State anomalies. This exception is thrown when a thread tries to wait for a monitor that does not own the object (O) or notifies other threads to wait for the object (O).

20, Java.lang.IllegalStateException

An abnormal state of law. This exception is thrown when the Java environment and the application are not already in the legal invocation state of a method, and the method is called.

21. java.lang.IllegalThreadStateException

An illegal thread state exception. An exception is thrown when the county seat is not in the legal calling state of a method and the method is called.

22. java.lang.InstantiationException

Instantiate the exception. This exception is thrown when an attempt is made to create an instance of a class through the newinstance () method, which is an abstract class or interface.

23. java.lang.InterruptedException

Aborted exception. This exception is thrown when a thread is in a long wait, hibernate, or other paused state while another thread terminates the thread through the interrupt method of the thread.

24. java.lang.NoSuchFieldException

No exception exists for the property. This exception is thrown when a property that does not exist for a class is accessed.

25. java.lang.RuntimeException

Run-time exception. is the parent class of exceptions that can be thrown during normal operation of all Java virtual machines.

26. java.lang.TypeNotPresentException

There is no exception for type.

27. Com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException:Cannot Delete or update a parent row:a FOREIGN KEY constraint fails (' MyDB '. ' Tb_room ', constraint ' room_hotel_id ' foreign key (' room_hotel_id ') REFERENCES ' Tb_h Otel ' (' hotel_id ') on the DELETE no action on UPDATE no action)

An external association does not allow cascading operations exceptions, cascade= "All", which allows cascading operations.

28. Org.springframework.beans.factory.UnsatisfiedDependencyException:Error creating Bean with Name ' Studentservice ' Defined in file

Cause: Studentservice not annotated @component object not found

29. Org.hibernate.engine.jndi.JndiException:Error parsing Jndi name []

Reason one: <session-factory name= "" > The default setting of the Name property is null, remove the attribute.

Summary of common exceptions in Java

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.