Tutorials References Exercises VideosMenu
Free WebsiteGet CertifiedPro

Java Tutorial

Java HOMEJava IntroJava Get StartedJava SyntaxJava OutputJava CommentsJava VariablesJava Data TypesJava Type CastingJava OperatorsJava StringsJava MathJava BooleansJava If...ElseJava SwitchJava While LoopJava For LoopJava Break/ContinueJava Arrays

Java Methods

Java MethodsJava Method ParametersJava Method OverloadingJava ScopeJava Recursion

Java Classes

Java OOPJava Classes/ObjectsJava Class AttributesJava Class MethodsJava ConstructorsJava ModifiersJava EncapsulationJava Packages / APIJava InheritanceJava PolymorphismJava Inner ClassesJava AbstractionJava InterfaceJava EnumsJava User InputJava DateJava ArrayListJava LinkedListJava HashMapJava HashSetJava IteratorJava Wrapper ClassesJava ExceptionsJava RegExJava ThreadsJava Lambda

Java File Handling

Java FilesJava Create/Write FilesJava Read FilesJava Delete Files

Java How To

Add Two NumbersCount WordsReverse a String

Java Reference

Java KeywordsJava String MethodsJava Math Methods

Java Examples

Java ExamplesJava CompilerJava ExercisesJava QuizJava Certificate


Java Keywords


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:

KeywordDescription
abstractA non-access modifier. Used for classes and methods: An abstract class cannot be used to create objects (to access it, it must be inherited from another class). An abstract method can only be used in an abstract class, and it does not have a body. The body is provided by the subclass (inherited from)
assertFor debugging
booleanA data type that can only store true and false values
breakBreaks out of a loop or a switch block
byteA data type that can store whole numbers from -128 and 127
caseMarks a block of code in switch statements
catchCatches exceptions generated by try statements
charA data type that is used to store a single character
classDefines a class
continueContinues to the next iteration of a loop
constDefines a constant. Not in use - use final instead
defaultSpecifies the default block of code in a switch statement
doUsed together with while to create a do-while loop
doubleA data type that can store whole numbers from 1.7e−308 to 1.7e+308
elseUsed in conditional statements
enumDeclares an enumerated (unchangeable) type
exportsExports a package with a module. New in Java 9
extendsExtends a class (indicates that a class is inherited from another class)
finalA non-access modifier used for classes, attributes and methods, which makes them non-changeable (impossible to inherit or override)
finallyUsed with exceptions, a block of code that will be executed no matter if there is an exception or not
floatA data type that can store whole numbers from 3.4e−038 to 3.4e+038
forCreate a for loop
gotoNot in use, and has no function
ifMakes a conditional statement
implementsImplements an interface
importUsed to import a package, class or interface
instanceofChecks whether an object is an instance of a specific class or an interface
intA data type that can store whole numbers from -2147483648 to 2147483647
interfaceUsed to declare a special type of class that only contains abstract methods
longA data type that can store whole numbers from -9223372036854775808 to 9223372036854775808
moduleDeclares a module. New in Java 9
nativeSpecifies that a method is not implemented in the same Java source file (but in another language)
newCreates new objects
packageDeclares a package
privateAn access modifier used for attributes, methods and constructors, making them only accessible within the declared class
protectedAn access modifier used for attributes, methods and constructors, making them accessible in the same package and subclasses
publicAn access modifier used for classes, attributes, methods and constructors, making them accessible by any other class
requiresSpecifies required libraries inside a module. New in Java 9
returnFinished the execution of a method, and can be used to return a value from a method
shortA data type that can store whole numbers from -32768 to 32767
staticA non-access modifier used for methods and attributes. Static methods/attributes can be accessed without creating an object of a class
strictfpRestrict the precision and rounding of floating point calculations
superRefers to superclass (parent) objects
switchSelects one of many code blocks to be executed
synchronizedA non-access modifier, which specifies that methods can only be accessed by one thread at a time
thisRefers to the current object in a method or constructor
throwCreates a custom error
throwsIndicates what exceptions may be thrown by a method
transientA non-accesss modifier, which specifies that an attribute is not part of an object's persistent state
tryCreates a try...catch statement
varDeclares a variable. New in Java 10
voidSpecifies that a method should not have a return value
volatileIndicates that an attribute is not cached thread-locally, and is always read from the "main memory"
whileCreates a while loop

Note:true, false, and null are not keywords, but they are literals and reserved words that cannot be used as identifiers.