Syntax errors are due to the fact that the syntax of the Java language is not respected.
Let us see some examples of syntax errors.
Example 1: Missing semicolon:
int a = 5 // semicolon is missing
Compiler message:
Example.java:20: ';' expected int a = 5
Example 2: Errors in expressions:
x = ( 3 + 5; // missing closing parenthesis ')' y = 3 + * 5; // missing argument between '+' and '*'