Once you click post assignment, learners in the selected class will immediately be able to see and complete this assignment
Back to Classroom
Syntax Errors
Java Syntax Course
Engineers From These Top Companies and Universities Trust EXLskills
1M+ Professionals | 100+ Institutions
This is the EXLskills free and open-source Java Syntax Micro Course. It guides learners via explanation, demonstration, and thorough practice, from no more than a basic understanding of Java, to a moderate level of understanding regarding Java syntax.
Is this course FREE?
Yes, this a 100% free course that you can contribute to on GitHub here!
Let's take a look at the example below, which will show us the last of the three most common errors, a Syntax Error.
SyntaxErrorExample.java
package exlcode;
public class SyntaxErrorExample {
/*
// public cannot be capitalized
// ints should be int
Public static ints exampleVariableOne = 5;
// static cannot be capitalized
public Static void main (String[] args){
// printline should be println
System.out.printline("Value of exampleVariableOne is " + exampleVariableOne);
}
*/
public static int exampleVariableOne = 5;
public static void main(String[] args) {
System.out.println("Value of exampleVariableOne is " + exampleVariableOne);
}
}
The code above shows a different set of variables and main method than the one outside the comments. The code inside the comments has syntax errors and would not compile if the comments were removed. A syntax error is similar to a grammatical error in the language of programming. One of the most common syntax errors is the misuse of Java reserved words. The program will compile but will then throw an error when seeing misformatted reserved words. Other syntax errors include misspelled variable and function names, missing semicolons, and mis-matching parentheses.
Syntax errors are among the easiest to resolve as most IDE tools we use to write Java point out syntax errors as you code.