+91 81900 98289

Java Keywords

A keyword is a reserved word. You cannot name a variable class, int, or new. The compiler already uses those words. If a name you want is reserved, add a noun: className, or item.

true, false, and null are literals, not names you can reuse. if, else, for, while, return, class, new, and static are the keywords these lessons use most often.

Example

boolean, true, if, and System are a mix of a keyword, a literal, a keyword, and a class name. Only open is a name you chose.

public class Keys { public static void main(String[] args) { boolean open = true; if (open) { System.out.println("open"); } } }
Editors color keywords so a reserved word is obvious. If the color changes on a name you invented, you picked a reserved word and the class will not compile.