java error countermeasures

This time I will write about the error that appears in java.

Compile error

Here are some compilation errors that are more common to beginners and how to deal with them.

And so on.

Insufficient semicolon ";"

The Java description rule is to add a semicolon ";" to each instruction.

semicolon";Is insufficient



public class HelloWorld {
	public static void main(String[] args) {
		System.out.println("Hello World!")  //← Semicolon ("";”) Is not enough
	}
}

Insufficient double quotation mark "" "

If you don't have enough double quotes "" "at the end of the string, you'll get this error:

Insufficient double quotation mark "" "


public class HelloWorld {
	public static void main(String[] args) {
		System.out.println("Hello World!);  ← World!After the""There is no
	}
}

Double-byte white space

This is caused by putting "full-width blank" characters in the place where "half-width blank" characters should be put.

Half-width white space



public □ class HelloWorld {		   //← Double-byte space after public (□)
	public static void main(String[] args) {
		System.out.println("Hello World!")  
	}
}

File name and class name are different

To give an example Whereas the class name described in the source file is "Hello World" It occurs because the file name is "Hello.java".

In Java, write one class in one file The file name is "class name.java".

Closing bracket "}"

Dozens of lines of programs lack parentheses for paragraphs like if () {} and for () {} It's very difficult to understand.

Closing bracket "}」


	public static void main(String[] args) {
		System.out.println("Hello World!")  
	// ← 「}There is no
}

Syntax error

It gets a little difficult, and I will introduce the error contents that appear in arrays and if syntax.

Click here for the main contents

java.lang.NullPointerException This error occurs when trying to access a null object. This error is relatively common during programming and is called "nullpo" by engineers.

Countermeasures

java.lang.ArrayIndexOutOfBoundsException An error that occurs when you specify an element that does not exist as an array index I also introduced the error example earlier. Where there are only 1-9 indexes as array indexes Occurs when trying to set a value for an index of 10.

Countermeasures

java.lang.NumberFormatException This error tried to convert (cast) a string value to a number Occurs when an incorrect numerical value is set in the character string.

Countermeasures

java.lang.ClassCastException This error occurs when trying to cast a class to a class that cannot be converted.

Countermeasures

java.lang.ArithmeticException This error occurs when an illegal arithmetic process is performed in the calculation of a numerical value. For example, this error occurs when a mathematically impossible "division by zero (10 ÷ 0, etc.)" occurs.

Countermeasures

java.lang.NoClassDefFoundError When calling a method or trying to create an instance This is an error that Java cannot read the class definition.

Countermeasures

java.lang.OutOfMemoryError Java uses two memory areas at runtime, the stack area and the heap area. This error occurs when the memory size of the heap area required to execute the program is insufficient.

A heap area is a memory area to which an instance of an object is allocated, such as class and method definitions.

Countermeasures

Recommended Posts

java error countermeasures
Today's java error
Countermeasures for Java OutOfMemoryError
Java Gold Countermeasures: Format
Java Gold Countermeasures: Localization
Confront Java Floating Point Error
Avoid Yubaba's error in Java
java setter getter error resolution
Java
Error when playing with java
Java
Summary of java error processing
Java learning (0)
Studying Java ―― 3
[Java] array
tomcat error
Java protected
[Java] Annotation
[Java] Module
Java array
Studying Java ―― 9
Java scratch scratch
Java tips, tips
Java methods
Java method
java (constructor)
Java array
[Java] ArrayDeque
java (override)
java (method)
Java string
java (array)
Java serialization
java beginner 4
JAVA paid
Eclipse error
Studying Java ―― 4
Java (set)
java shellsort
[Java] compareTo
Studying Java -5
java reflexes
java (interface)
Java memorandum
☾ Java / Collection
Java array
Studying Java ―― 1
[Java] Polymorphism
Studying Java # 0
Java review
Java features
[Java] Inheritance
Deployment error
FastScanner Java
Java features
Error memorandum
Java memo
java (encapsulation)
Java inheritance
[Java] Overload
Java basics