elibraryportal Logo

Keywords in Java

Reserved words are also known as Java keywords Where reserved words cannot be used as variables, methods, classes, or any other identifiers:

List of Java Keywords

SL.NOKeywordDescription
1.abstractAn abstract keyword is used to declare as abstract class. Abstract class can provide the implementation of interface. It can have abstract and non-abstract methods.
2.booleanJava boolean keyword is used to declare a variable as a boolean type. It can hold True and False values only.
3.breakbreak keyword are used in loop or switch statement.
4.casecase keyword are used in the switch statements to mark blocks of text.
5.catch In Java catch keyword are used in an exceptions generated by try statements. It must be used after the try block only.
6.char char keyword are used in data type that is used to store a single character.
7.classclass keyword are used for declare a class.
8.continueIt continues the current flow of the program and skips the remaining code at the specified condition.
9.defaultdefault keyword are used to specify the default block of code in a switch statement.
10dodo keyword are used in control statement to declare a loop. It can iterate a part of the program several times.
11.doubledouble keyword are used to declare a variable that can hold a 64-bit floating-point numbers.
12.elseelse keyword are used to indicate the alternative branches in an if statement.
13.enumenum keyword are used to define a fixed set of constants. Enum constructors are always private or default.
14.extendsextends keyword are used to indicate that a class is derived from another class or interface.
15.finalfinal keyword are used to indicate that a variable holds a constant value. It is applied with a variable. It is used to restrict the user.
16.finally finally keyword indicates a block of code in a try-catch structure. This block is always executed whether exception is handled or not.
17.floatfloat keyword is used to declare a variable that can hold a 32-bit floating-point number.
18.forfor keyword are used to start a for loop. It is used to execute a set of instructions/functions repeatedly when some conditions become true. If the number of iteration is fixed, it is recommended to use for loop.
19.ifif keyword test the condition. It executes the if block if condition is true.
20.implementsimplements keyword are used to implement an interface.
21.import import keyword makes classes and interfaces available and accessible to the current source code.
22.instanceofinstanceof keyword is used to test whether the object is an instance of the specified class or implements an interface.
23.intint keyword is used to declare a variable that can hold a 32-bit signed integer.
24.interfaceinterface keyword is used to declare an interface. It can have only abstract methods.
25.longlong keyword is used to declare a variable that can hold a 64-bit integer.
26.nativeSpecifies that a method is implemented with native (platform-specific) code
27.newnew keyword is used to create new objects.
28.nullnull keyword are used to indicate that a reference does not refer to anything. It removes the garbage value.
29.packagepackage keyword are used to declare a Java package that includes the classes.
30privateprivate keyword is an access modifier. It is used to indicate that a method or variable may be accessed only in the class in which it is declared.
31.protectedprotected keyword is an access modifier. It can be accessible within package and outside the package but through inheritance only. It can't be applied on the class.
32.publicpublic keyword is an access modifier. It is used to indicate that an item is accessible anywhere. It has the widest scope among all other modifiers.
33.returnreturn keyword is used to return from a method when its execution is complete.
34.shortshort keyword is used to declare a variable that can hold a 16-bit integer.
35.staticstatic keyword is used to indicate that a variable or method is a class method. The static keyword in Java is used for memory management mainly.
36.supersuper keyword is a reference variable that is used to refer parent class object. It can be used to invoke immediate parent class method.
37.switchswitch keyword contains a switch statement that executes code based on test value. The switch statement tests the equality of a variable against multiple values.
38.synchronizedsynchronized keyword is used to specify the critical sections or methods in multithreaded code.
39.thisthis keyword can be used to refer the current object in a method or constructor.
40.throwJava throw keyword is used to explicitly throw an exception. The throw keyword is mainly used to throw custom exception. It is followed by an instance.
41.throwsJava throws keyword is used to declare an exception. Checked exception can be propagated with throws.
42.transienttransient keyword is used in serialization. If you define any data member as transient, it will not be serialized.
43.trytry keyword is used to start a block of code that will be tested for exceptions. The try block must be followed by either catch or finally block.
44.voidvoid keyword is used to specify that a method does not have a return value.
45.volatilevolatile keyword is used to indicate that a variable may change asynchronously.
46.while:while keyword is used to start a while loop. This loop iterates a part of the program several times. If the number of iteration is not fixed, it is recommended to use while loop.
47.strictfpstrictfp is used to restrict the floating-point calculations to ensure portability.