Exception types that occur in Java

Source: Internet
Author: User

Java the type of exception that appears in

Missing format parameter exception

java.util.MissingFormatArgumentException Exception

Error message:

java.util.MissingFormatArgumentException:
Format specifier ' s '

Cause: string formatting provides fewer values than the number of string format characters (%s)

Parameters:
Format-A formatted string that is described in the syntax of a format string
Args-the parameter referenced by the format specifier in the format string. If the arguments are more than the format specifier, the extra arguments are ignored. The number of parameters is variable and can be zero. The maximum number of parameters is limited by the maximum dimensions of the Java array defined by Java Virtual Machine specification. The behavior of the null parameter depends on the conversion.

Number Format exception

Java.lang.NumberFormatException

Error message:

Java.lang.NumberFormatException: For input string: "1"

Reason: This statement explicitly tells us that the number format is abnormal, followed by a for input string: "1" hint, this tells us that you want to convert "1" to a numeric type error.

Null pointer exception

Java.lang.NullPointerException

Error message:

ExceptionIn thread "main":java.lang.NullPointerException

cause: null pointer exception. This exception is thrown when an app tries to use null where the object is required. For example: Call an instance method of a Null object, access the properties of a null object, evaluate the length of a null object, throw null with a throw statement, and so on.

Note:

There are several reasons for the general report java.lang.NullPointerException:
1) • The string variable is not initialized;
2) • Objects of the interface type are not initialized with a specific class, such as:
List lt; Will error
List lt = new ArrayList (); You won't get an error.
3) • When the value of an object is empty, you are not judged to be empty.

Array out of bounds exception (index out of bounds exception)

Java.lang.IndexOutOfBoundsException

Error message:

java.lang.IndexOutOfBoundsException : index:0, size:0

Cause: index out-of-bounds exception. This exception is thrown when an index value that accesses a sequence is less than 0 or greater than or equal to the sequence size.

File not found exception

Java.io.FileNotFoundException

Error message:

Java.io.FileNotFoundException:File does not exist
Cause: This is an IO exception, and the English obvious hint is that the file cannot be found, indicating that the path of file is not written.

Exception types that occur 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.