Java Keywords List | How Many Keywords In Java?

  In this section, we will learn about Java Keywords, Java Keywords is also known as a reserved keyword. Java has a total of 52 keywords. Out of these 52 keywords, 49 are in use, 1 is in preview, and 2 are not in use.

Java Keywords

Java Keywords is also known as a reserved keyword. Java has a total of 52 reserved keywords that have predefined meaning in Java Programming Language. Reserved Keywords cannot be used as identifier name of the class, variable, and any methods.

List of Java Keywords

Java provides a total 52 keyword as listed below:

SN Keywords Description
1 _ Added in Java 9, the underscore has become a keyword and cannot be used as a variable name anymore.
2 abstract An abstract keyword is used to declare an abstract class or method. A method with no definition can be created using an abstract keyword inside the class that must be an abstract class. The definition of the abstract method must be implemented in its driven class or sub-class. An abstract class can contain both non-abstract methods and abstract methods. The Abstract Keywords cannot be used with constructors and variables.
3 assert It is used during the program development to create an assertion, assertion is a condition that should be true during the execution of the program. At run time, if the assertion condition is true, no other action will be taken. However, if the condition is false, it raises an AssertionError. Assert keyword has two forms: 1. assert condition 2. assert condition: expression.
4 boolean Boolean is a primitive data type, for logical values. Boolean can able to hold either true or false.
5 break Java break keyword is used to force the program to immediate termination of execution of the current running loop. With a break keyword, it terminates the current loop and runs the next statements.
6 byte Java byte keyword used to hold the 8-bit signed two's complement integer.
7 case A switch statements use a case keyword to control their execution flow, When the switch condition executed it check for the label with the case, and default keyword. For example, case 1 here, 1: is a label.
8 catch Java catch keyword is used to catch an exception at run time, catch keyword used after the try keyword blocks.
9 char Use to define a character variable that can hold unsigned 16-bit Unicode characters.
10 class A class is used to give the definition of an object. Class keywords define an instance, method, fields as well an inner class.
11 const Unused keyword, which is used to set a constant value that cannot be changed once initialized.
12 continue Java Continue keyword is used inside the loop which helps to continue the loop at specific conditions. It skips all the statements after the Continue keyword at specified conditions inside the loop block.
13 default Java default keyword is used in switch statements, when no case matched with specified value then the default will execute.
14 do Java do keyword is used in conjunction with the while keyword to create a do-while loop.
15 double Java double is used to hold the floating number, Java double can hold 64-bit double-precision IEEE 754 floating-point number.
16 else Else keyword is used with if statements, if the condition of it is false then alternative statements will execute indicate by else keyword.
17 enum It is used to define a fixed set of constants. Enumerations extend the base class enum.
18 extends Java extends keyword is used to derived another class property, extends define the inheritance property of another class.
19 final Java Final keyword, indicates the variable to hold the constant value that cannot be changed later once initialized.
20 finally Java finally Keyword is used with try-catch structure block to catch run time exceptions. Finally block of statements always executes whether exceptions occur or not.
21 float Java float keyword indicates to a variable to hold the floating-point number, float can hold 32-bit single-precision IEEE 754 floating-point number.
22 for For keyword used in loop to control the statements, For Example: for(int i=0;i<=10;i++)
23 goto Unused keyword, goto keyword indicates to jump to the given label.
24 if Java IF keyword is used to control the block, If the condition is true it will execute the if block otherwise not.
25 implements Java Implements Keywords is used to implement the interface in a derived class, by implementing the interface you can give a definition of functions.
26 import Java import keyword indicates is used to import the internal or external packages inside the program to use methods and variables.
27 instanceof Java instanceof keyword is used to check the type of instance whether the instance is for a specific class/interface or not.
28 int Java int keyword is used to declare a variable that can hold a 32-bit signed two's complement integer.
29 interface Java interface keyword is used to declare special types of class that contain default methods and abstract, it needs to implemented in derived class using implements keyword.
30 long Java long keyword is used to declare a variable that can hold a floating-point number, 64-bit signed two's complement integer.
31 native Java native keyword indicates that the written source code is not in java code, but rather in another language.
32 new Java new keyword is used to create an instance of the user-defined class or any built-in class like an array, Double, Integer, etc.
33 non-sealed Java non-sealed class is used to declare a class or interface which extends the sealed class can be extended further by an unknown class.
34 package Java package keywords indicate the group of built-in or user-defined similar classes and interfaces.
35 private Java private keyword is used to declare a method, data members, and inner-class, private members can only be accessed by other members of their own class. Java private keyword is an access modifier.
36 protected Java protected keyword is used while declaring a method, data members, and inner-class, which can be accessed by members of their own class, It can be accessed by their own sub-class or classes inside the same package.
37 public Java public keyword is used while declaring a method, data members, and inner-class, which can be accessed by any classes whether the package is the same or not.
38 return Java return keyword used to return the data members to the caller from methods.
39 short Java short keyword is used to declare a variable that can hold 16-bit signed two's complement integer.
40 static Java static keyword is used to define the methods that don't need to create an object to access that method from their own class, by using static keyword it can be possible. Static keyword is used for memory management.
41 strictfp Java keyword is used to restrict the rounding and precision of floating-point calculations to ensure portability.
42 super Java super keyword is used to access the members of a class inherited by the class in which the super keyword appears. Supper keyword allows invoking the constructors of the parent class.
43 switch Java switch keyword is used to control the statements, it is used with the conjunction of case and default.
44 synchronized Java synchronized keyword is used to work efficiently with multi-thread, manage the critical section and method in multi-thread.
45 this Java this keyword is used to access the data members having the same name which are declared as a global, it can be accessed from the methods that contain a variable having the same name defined as globally. It also refers to the constructors and methods.
46 throw Java throw keyword is used to throw an exception when it occurs, used in the conjunction of try, catch, and finally.
47 throws Java throws keyword is used with methods to specify which method is not able to handle an exception inside a method. It throws all the exceptions to the higher program.
48 transient Java transient keyword is used when an object is serialized, Transient variables are not saved by the serialization facilities.
49 try Java try keyword is used to declare a block of statements where is the possibility to occur an exception. When an exception occurs it throws the exception to the catch block with the help of the throw keyword.
50 void Java void keyword specifies a method that doesn't have any return value.
51 volatile Java volatile keyword is used to declare a variable that performs read/write operation in main memory When java read the volatile variable from main memory directly.
52 while Java while keyword is used to create a while-loop, while-loop uses the boolean expression to execute their statements.

Reserved words for literal values

SN Keywords Description
1 true Java true keyword, used in an expression to check whether the condition meets the requirements or not. Used in loop and control statements. True also represented as one(1)
2 false Java false keyword, used in an expression to check whether the condition is false or not. False also represented as zero(0).
3 null Java null keyword refers to the empty, It reset the garbage value.

How Many Keywords In Java ?

Java has a total of 52 keywords (updated in Java 9). Out of these 52 keywords, 49 are in use, 1 is in preview, and 2 are not in use.


Announcement
Advertisement