
Program errors can be abstractly divided into three categories: grammatical errors, operational errors and logical errors.
1. Syntax errors
are caused by input that does not conform to grammatical rules during programming. The program cannot be compiled and the program cannot be run. This type of error is the simplest and easier to debug.
Example:
The expression is incomplete, the necessary punctuation is missing, the keyword is entered incorrectly, the data type does not match, the keyword of the loop statement or selection statement is incorrect. Match etc. Usually, when the compiler compiles a program, it will list the detected syntax errors in a prompt, also called compilation errors.
Solution:
The debugging of syntax errors can be achieved by the debugging function provided by the integrated development environment. When the program is compiled, the compiler will Diagnose syntax errors in .
2. Running errors
refers to errors that occur during the running of the program. The program passes syntax error detection, but an error occurs during running, causing the program to be forced to terminate. Such errors have specific occurrence conditions, so the faulty code segment can be accurately located, making debugging more convenient.
Example:
The divisor during division operation is 0, the array subscript is out of bounds, the file cannot be opened, the disk space is not enough, the database connection error, etc.
Solution:
When such errors occur, the compilation platform will generally prompt corresponding information. For regular errors, there will be more precise prompts, but sometimes The cause of the error prompted will be relatively vague, but because this type of error generally occurs only under specific conditions when the program is running, so based on the conditions under which the error occurs, the code section of the program error can be roughly determined, and combined with the cause of the error, It can also make debugging errors easier.
3. Logic error
After the program is run, the results expected by the designer are not obtained, which means that there is a logic error in the program. This error is syntactically valid but logically incorrect.
Example:
Incorrect variables are used, the order of instructions is wrong, the conditions of the loop are incorrect, the programming algorithm is not fully considered, etc.
Solution:
Usually, logic errors will also produce runtime errors. Under normal circumstances, when the compiler compiles a program, it cannot detect logic errors in the program, and will not generate logic error prompts. Therefore, logic errors are difficult to eliminate. Programmers need to carefully analyze the program and use an integrated development environment. Only with the provided debugging tools can we find the cause of the error and eliminate it.
Recommended tutorial: Java tutorial
The above is the detailed content of What are the types of errors in java?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Chinese version
Chinese version, very easy to use

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool





