This article gives you an overview of all keywords in the Java programming language with explanation and code examples (updated to Java 14). Understand the meaning of each Java keyword will help you write better and more precise code, e.g. know when to use public or private for a variable or class.
Beginners in Java programming will find the list below helpful in terms of getting started with Java from the ground up. And senior Java programmers will also find this article helpful in terms of reviewing all Java keywords updated to the most recent release of Java.
You know, the Java programming language has over 50 reserved keywords which have special meaning for the compiler and cannot be used as variable names. Following is a list of Java keywords in alphabetical order. You can click on an individual keyword to see its description and usage example.
Some noteworthy points regarding Java keywords:
And based on categories, the keywords in Java can be grouped as follows:
Java keywords for access modifiers: private, protected, public
Java keywords for class, method, variable modifiers:
abstract, class, default, extends, final,
implements, interface, native, new,
static, strictfp, synchronized, transient,
Java keywords for Flow control:
break, case, continue, default, do, else,
for, if, instanceof, return, switch, while,
Java keywords for package control: import, package
Java keywords for primitive types: boolean, byte, char,
double, float, int, long, short
Java keyword for error handling: assert, catch, finally,
Java keyword for enumeration: enum
Other Java keywords: super, this, void
Unused (reserved) Java keywords: const, goto