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.

 

List of all keywords in Java (updated to Java 14):

abstractassertboolean
breakbytecase
catchcharclass
constcontinuedefault
dodoubleelse
enumextendsfinal
finallyfloatfor
gotoifimplements
importinstanceofint
interfacelongnative
new package private
protectedpublicreturn
shortstaticstrictfp
superswitchsynchronized
thisthrowthrows
transienttryvoid
volatilewhilevar
recordyield 
 

Some noteworthy points regarding Java keywords:

    • const and goto are resevered words but not used.
    • true, false and null are literals, not keywords.
    • Since Java 8, the default keyword is also used to declare default methods in interfaces.
    • Since Java 10, the word var is used to declare local variables (local variables type inference). For backward compatibility, you can still use var as variable names. So var is a reserved word, not keyword.
    • Java 14 adds two new keywords record and yield (but in preview mode)
    • all keywords are in lower-case.
 

And based on categories, the keywords in Java can be grouped as follows:

 



Java keywords for access modifiers: privateprotected, public

Java keywords for class, method, variable modifiers:

abstractclassdefaultextendsfinal

implementsinterfacenativenew

staticstrictfpsynchronizedtransient

var, recordvolatile

 

Java keywords for Flow control:

breakcasecontinuedefaultdoelse

forifinstanceofreturnswitchwhile,

yield

 

Java keywords for package control: importpackage

 

Java keywords for primitive types: booleanbytechar

doublefloatintlongshort

 

Java keyword for error handling: assertcatchfinally

throwthrowstry

 

Java keyword for enumeration: enum

Other Java keywords:  superthisvoid

Unused (reserved) Java keywords: const, goto 

 

Other Recommended Tutorials:


About the Author:

is certified Java programmer (SCJP and SCWCD). He began programming with Java back in the days of Java 1.4 and has been passionate about it ever since. You can connect with him on Facebook and watch his Java videos on YouTube.



Add comment

   


Comments 

#18Prasad Chougale2023-03-06 02:55
Nice tutorials its very simple and useful
Quote
#17Chris Owens2022-09-25 11:50
good turtorial.. Followed!
Quote
#16Nam2022-07-15 18:31
To Jona: Yes, use can. And please cite source CodeJava.net when using my materials. Thanks.
Quote
#15Jona2022-07-15 15:32
Thank you so much please can you give more detailed explanation and can I request permission to use your explanation to teach others
Quote
#14Klufi Foreman2019-12-09 01:05
I'm new to java. Interested to learn.
Quote