Java Keywords

Keywords in Java are reserved words that have predefined meanings in the language and cannot be used as identifiers for variables, classes, methods, or any other entities.

Key Topics

1. List of Java Keywords

Below is the complete list of Java keywords:

Keyword Description
abstractSpecifies that a class or method is abstract
assertUsed for debugging purposes
booleanPrimitive data type for true/false values
breakExits a loop or switch
bytePrimitive data type for 8-bit integers
caseA case in a switch statement
catchCatches exceptions generated by try statements
charPrimitive data type for 16-bit Unicode characters
classDefines a class
constReserved but not used
continueSkips the current iteration of a loop
defaultDefault case in a switch statement
doStarts a do-while loop
doublePrimitive data type for double-precision 64-bit floating point
elseAlternative path in an if statement
enumDefines an enumerated type
extendsIndicates that a class is derived from another class
finalDefines an entity that cannot be changed or inherited
finallyBlock of code that always executes after try/catch
floatPrimitive data type for single-precision 32-bit floating point
forStarts a for loop
gotoReserved but not used
ifStarts a conditional statement
implementsIndicates that a class implements an interface
importIncludes classes and interfaces from other packages
instanceofTests whether an object is an instance of a class
intPrimitive data type for 32-bit integers
interfaceDefines an interface
longPrimitive data type for 64-bit integers
nativeIndicates that a method is implemented in native code
newCreates new objects
nullRepresents a null reference
packageDeclares a Java package
privateAccess modifier for private access
protectedAccess modifier for protected access
publicAccess modifier for public access
returnExits from a method, optionally returning a value
shortPrimitive data type for 16-bit integers
staticIndicates that a variable or method is static
strictfpRestricts floating-point calculations to ensure portability
superRefers to superclass objects
switchStarts a switch statement
synchronizedIndicates that a method or block is synchronized
thisRefers to the current object
throwThrows an exception
throwsDeclares exceptions that a method might throw
transientIndicates that a field is not part of the serialization
tryStarts a block of code that might throw an exception
voidIndicates that a method does not return any value
volatileIndicates that a variable may be modified asynchronously
whileStarts a while loop

Key Takeaways

  • Java has a set of reserved keywords that have special meanings.
  • These keywords cannot be used as identifiers in your code.
  • Understanding these keywords is essential for reading and writing Java programs.