Java Reserved Keywords
Java has a set of keywords that are reserved words that cannot be used as
variables, methods, classes, or any other identifiers:
Keyword Description
abstract A non-access modifier. Used for classes and methods: An abstra
access it, it must be inherited from another class). An abstract m
and it does not have a body. The body is provided by the subcla
assert For debugging
boolean A data type that can only store true and false values
break Breaks out of a loop or a switch block
byte A data type that can store whole numbers from -128 and 127
case Marks a block of code in switch statements
catch Catches exceptions generated by try statements
char A data type that is used to store a single character
class Defines a class
continue Continues to the next iteration of a loop
const Defines a constant. Not in use - use final instead
default Specifies the default block of code in a switch statement
do Used together with while to create a do-while loop
double A data type that can store whole numbers from 1.7e−308 to 1.7
else Used in conditional statements
enum Declares an enumerated (unchangeable) type
exports Exports a package with a module. New in Java 9
extends Extends a class (indicates that a class is inherited from another c
final A non-access modifier used for classes, attributes and methods,
(impossible to inherit or override)
finally Used with exceptions, a block of code that will be executed no m
float A data type that can store whole numbers from 3.4e−038 to 3.4
for Create a for loop
goto Not in use, and has no function
if Makes a conditional statement
implements Implements an interface
import Used to import a package, class or interface
instanceof Checks whether an object is an instance of a specific class or an
int A data type that can store whole numbers from -2147483648 to
interface Used to declare a special type of class that only contains abstrac
long A data type that can store whole numbers from -922337203685
module Declares a module. New in Java 9
native Specifies that a method is not implemented in the same Java sou
new Creates new objects
package Declares a package
private An access modifier used for attributes, methods and constructor
declared class
protected An access modifier used for attributes, methods and constructor
package and subclasses
public An access modifier used for classes, attributes, methods and con
other class
requires Specifies required libraries inside a module. New in Java 9
return Finished the execution of a method, and can be used to return a
short A data type that can store whole numbers from -32768 to 32767
static A non-access modifier used for methods and attributes. Static m
creating an object of a class
strictfp Restrict the precision and rounding of floating point calculations
super Refers to superclass (parent) objects
switch Selects one of many code blocks to be executed
synchronized A non-access modifier, which specifies that methods can only be
this Refers to the current object in a method or constructor
throw Creates a custom error
throws Indicates what exceptions may be thrown by a method
transient A non-accesss modifier, which specifies that an attribute is not p
try Creates a try...catch statement
var Declares a variable. New in Java 10
void Specifies that a method should not have a return value
volatile Indicates that an attribute is not cached thread-locally, and is al
while Creates a while loop
Note: true, false, and null are not keywords, but they are literals and reserved
words that cannot be used as identifiers.