The major errors makes for beginners in simple java code

java dev.to

=> Java, keywords and class names are case-sensitive.

=> Java keywords like (public, class, static, void) must be in lowercase.

Error 1

public must be in lowercase because it's a keyword in java.

✓ Change public static Game instead of Public static Game

Error 2

class is a valid Java keyword.

Class is not the keyword for defining a class.

class is a reserved keyword in Java and must written in lowercase.

Error 3

=> Java class names like (String, System, Scanner) usually start with an uppercase letter.

Stringis a built in Java class, so the S must be uppercase.

Error 4

System is also a built in java class, so the S must be uppercase.

Error 5

✓ In the line 5 end of printlnmissing a semicolan(;)

✓ Semicolan marks the end of a statement in java.

✓ Without semicolon (;) the statement not end.

Error 6

✓ In this code missing the curley braces { after the class declaration.

✓ Without the curley braces { java doesn't know where the class begin.

Error 7

✓ Missing dots(.) between system out println.

✓ without the dots,java cannot understand the relationship between system,out and println, and you'll get the compilation errors.

✓ Without the dots, java sees seperate words and doesn't know how they are connected.

✓ So write system.out.println instead of system out println

Error 8

✓ In this code error occurs in the main method parameter,because args is array of strings, not a single String.

✓Java store the values in array like,

args[0]="Hello"
args[1]="world"
Enter fullscreen mode Exit fullscreen mode

✓If you not write (string[]args) your code will compile successfully,because String args is a valid method parameter.

✓ But,when you run the code you'll get the output what I got.

java Game
Enter fullscreen mode Exit fullscreen mode

✓ So must write the public static void main(String[]args)

Correct Code

Source: dev.to

arrow_back Back to Tutorials