Java Keywords - Keywords in Java , List of all Java Keywords
Java Reserved Keywords
Java Keywords and Definitions
Keywords in Java
Java Keywords
Java keywords are also known as reserved words . Keywords are particular words which acts as a key to a code . In the Java programming language , a keyword is any one of 57 reserved words . Java keywords have a predefined meaning in the language because of this , programmers cannot use keywords as names for variables , methods , classes , or as any other identifier . Out of 57 keywords , 55 are in use and 2 are not in use . This definition is also same for the following questions .
- what are keywords in Java ?
- What are Java programming language keywords ?
- What are java keywords and their definitions ?
- Different keywords in Java
- Java Keywords and their uses
What is Keyword in Java ?
The keyword is any one of 57 reserved words in Java .
What is Reserved Word in Java ?
Reserved Word have a predefined meaning in the Java programming language .
How many keywords in Java ?
There are 57 keywords in Java programming language . Programmers cannot use keywords as names for variables , methods , classes , or as any other identifier .
List of All Java Keywords
List of Java Keywords
Java Keywords List
abstract | continue | for | new | switch |
assert | default | goto | package | synchronized |
boolean | do | if | private | this |
break | double | implements | protected | throw |
byte | else | import | public | throws |
case | enum | instanceof | return | transient |
catch | extends | int | short | try |
char | final | interface | static | void |
class | finally | long | strictfp | volatile |
const | float | native | super | while |
true | false | null | var | |
Following Java Keywords are added in Java 9 or later | ||||
exports | module | requires | var |
Following are the List of all Java Keywords or reserved words and their Definitions . In the list all the Java keywords are covered .
List of all Java Keywords and their Definitions
What are the List of all Java Keywords ?
Java Keywords or Java Reserved words are the words in a language that are used for some internal process or represent some predefined actions . These words are therefore not allowed to use as a variable names or objects . Doing this will result into a compile time error .
What is assert Keyword in Java ?
An assertion is a statement in the Java programming language that enables you to test your assumptions about your program . Assert describes a predicate (a true–false statement) placed in a Java program to indicate that the developer thinks that the predicate is always true at that place . If an assertion evaluates to false at run-time , an assertion failure results , which typically causes execution to abort . Optionally enable by ClassLoader method .
What is abstract Keyword in Java ?
Java abstract keyword is used to declare abstract class . Abstract class can provide the implementation of interface . It can have abstract and non-abstract methods . Java abstract keyword used in a class definition to specify that a class is not to be instantiated , but rather inherited by other classes . An abstract class can have abstract methods that are not implemented in the abstract class , but in subclasses .
What is abstract class in Java ?
Java abstract class that contains one or more abstract methods , and therefore can never be instantiated . Abstract classes are defined so that other classes can extend them and make them concrete by implementing the abstract methods .
What is abstract method in Java ?
Java abstract method that has no implementation .
What is assert Keyword in Java ?
An assertion is a statement in the Java programming language that enables you to test your assumptions about your program . Assert describes a predicate (a true–false statement) placed in a Java program to indicate that the developer thinks that the predicate is always true at that place . If an assertion evaluates to false at run-time , an assertion failure results , which typically causes execution to abort . Optionally enable by ClassLoader method .
What is boolean Keyword in Java ?
Java boolean keyword is used to declare a variable as a boolean type . It can hold True and False values only . Refers to an expression or variable that can have only a true or false value . The Java programming language provides the boolean type and the literal values true and false . The default value of boolean is false . This keyword is also used to declare that a method returns a value of the primitive type boolean .
What is break Keyword in Java ?
Java break keyword is used to break loop or switch statement . It breaks the current flow of the program at specified condition . Java break keyword used to resume program execution at the statement immediately following the current statement . If followed by a label , the program resumes execution at the labeled statement .
What is byte Keyword in Java ?
Java byte keyword is used to declare a variable that can hold an 8-bit data values . The byte keyword is used to declare a field that can hold an 8-bit signed two's complement integer . This keyword is also used to declare that a method returns a value of the primitive type byte .
What is case Keyword in Java ?
Java case keyword is used to with the switch statements to mark blocks of text . The Java case keyword that defines a group of statements to begin executing if a value specified matches the value defined by a preceding switch keyword . A statement in the switch block can be labeled with one or more case or default labels . The switch statement evaluates its expression , then executes all statements that follow the matching case label; see switch .
What is catch Keyword in Java ?
Java catch keyword is used to catch the exceptions generated by try statements . It must be used after the try block only . The Java catch keyword is used to declare a block of statements to be executed in the event that a Java exception , or run time error , occurs in a preceding try block .
What is char Keyword in Java ?
Java char keyword is used to declare a variable that can hold unsigned 16-bit Unicode characters . Defines a character variable capable of holding any character of the java source file's character set . The default value of a char data type is '\u0000' .
What is class Keyword in Java ?
Java class keyword is used to declare a class . In the Java programming language , a type that defines the implementation of a particular kind of object . A class definition defines instance and class variables and methods , as well as specifying the interfaces the class implements and the immediate superclass of the class . If the superclass is not explicitly specified , the superclass will implicitly be Object . The class keyword can also be used in the form Class .class to get a Class object without needing an instance of that class . For example , String.class can be used instead of doing new String().getClass() .
What is class method in Java ?
A method that is invoked without reference to a particular object . Class methods affect the class as a whole , not a particular instance of the class . Also called a static method .
What is class variable in Java ?
A data item associated with a particular class as a whole--not with particular instances of the class . Class variables are defined in class definitions . Also called a static field .
What is Classpath in Java ?
An environmental variable which tells the Java Virtual Machine and Java technology-based applications where to find the class libraries , including user-defined class libraries .
What is const Keyword in Java ?
A reserved Java keyword not used by current versions of the Java programming language .
What is continue Keyword in Java ?
Java continue keyword is used to continue the loop . It continues the current flow of the program and skips the remaining code at the specified condition . A Java keyword used to resume program execution at the end of the current loop . If followed by a label , continue resumes execution where the label occurs .
What is default Keyword in Java ?
Java default keyword is used to specify the default block of code in a switch statement . A Java keyword optionally used after all case conditions in a switch statement . If all case conditions are not matched by the value of the switch variable , the default keyword will be executed .
What is do Keyword in Java ?
Java do keyword is used in control statement to declare a loop . It can iterate a part of the program several times . A Java keyword used to declare a loop that will iterate a block of statements . The loop's exit condition can be specified with the while keyword .
What is double Keyword in Java ?
Java double keyword is used to declare a variable that can hold a 64-bit floating-point numbers . A Java keyword used to define a variable of type double .
What is double precision in Java ?
In the Java programming language specification , describes a floating point number that holds 64 bits of data .
What is else Keyword in Java ?
Java else keyword is used to indicate the alternative branches in an if statement . A Java keyword used to execute a block of statements in the case that the test condition with the if keyword evaluates to false .
What is enum Keyword in Java ?
Java enum keyword is used to define a fixed set of constants . enum constructors are always private or default . A Java keyword used to declare an enumerated type .
What is exports Keyword in Java ?
Used in modular java to export a package with a module . This keyword is only available in Java 9 and later .
What is extends Keyword in Java ?
Java extends keyword is used to indicate that a class is derived from another class or interface . extends is a Java keyword used to inherit the properties and methods of another class . class X extends class Y to add functionality , either by adding fields or methods to class Y , or by overriding methods of class Y . An interface extends another interface by adding methods . Class X is said to be a subclass of class Y .
What is final Keyword in Java ?
Java final keyword is used to indicate that a variable holds a constant value . If you declare class , method or field those are not modifiable at any point after declaration . A final class cannot be subclassed , a final method cannot be overridden and a final variable cannot change from its initialized value .
What is finally Keyword in Java ?
Java finally keyword indicates a block of code in a try-catch structure . This block is always executed whether exception is handled or not . A Java keyword that executes a block of statements regardless of whether a Java Exception , or run time error , occurred in a block defined previously by the try keyword .
What is float Keyword in Java ?
Java float keyword is used to declare a variable that can hold a 32-bit floating-point number . A Java keyword used to define a floating point number variable .
What is for Keyword in Java ?
Java for keyword is used to start a for loop . It is used to execute a set of instructions or functions repeatedly when some conditions become true . If the number of iteration is fixed , it is recommended to use for loop . A Java keyword used to declare a loop that reiterates statements . The programmer can specify the statements to be executed , exit conditions , and initialization variables for the loop .
What is goto keyword in Java ?
It is not used by current versions of the Java programming language .
What is if Keyword in Java ?
Java if keyword tests the condition . It executes the if block if condition is true . A Java keyword used to conduct a conditional test and execute a block of statements if the test evaluates to true .
What is implements Keyword in Java ?
Java implements keyword is used to implement an interface . A Java keyword included in the class declaration to specify any interfaces that are implemented by the current class .
What is import Keyword in Java ?
Java import keyword makes classes and interfaces available and accessible to the current source code . A Java keyword used at the beginning of a source file that can specify classes or entire packages to be referred to later without including their package names in the reference .
What is instanceof Keyword in Java ?
Java instanceof keyword is used to test whether the object is an instance of the specified class or implements an interface . A two-argument Java keyword that tests whether the runtime type of its first argument is assignment compatible with its second argument .
What is int Keyword in Java ?
Java int keyword is used to declare a variable that can hold a 32-bit signed integer . A Java keyword used to define a variable of type integer .
What is interface Keyword in Java ?
Java interface keyword is used to declare an interface . It can have only abstract methods . A Java keyword used to define a collection of method definitions and constant values . It can later be implemented by classes that define this interface with the " implements " keyword .
What is long Keyword in Java ?
Java long keyword is used to declare a variable that can hold a 64-bit integer . A Java keyword used to define a variable of type long .
What is module Keyword in Java ?
The module keyword is used to declare a module inside of a Java application . This keyword is only available in Java 9 and later .
What is native Keyword in Java ?
Java native keyword is used to specify that a method is implemented in native code using JNI ( Java Native Interface ). A Java keyword that is used in method declarations to specify that the method is not implemented in the same Java source file , but rather in another language .
What is new Keyword in Java ?
Java new keyword is used to create new objects . A Java keyword used to create an instance of a class .
What is package Keyword in Java ?
Java package keyword is used to declare a Java package that includes the classes . A group of types . Packages are declared with the package keyword .
What is private Keyword in Java ?
Java private 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 . A Java keyword used in a method or variable declaration . It signifies that the method or variable can only be accessed by other elements of its class .
What is protected Keyword in Java ?
Java protected 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 . A Java keyword used in a method or variable declaration . It signifies that the method or variable can only be accessed by elements residing in its class , subclasses , or classes in the same package .
What is public Keyword in Java ?
Java public 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 . A Java keyword used in a class , method or variable declaration . It signifies that the method or variable can be accessed by elements residing in other classes .
What is requires Keyword in Java ?
Used to specify the required libraries inside of a module . This keyword is only available in Java 9 and later .
What is return Keyword in Java ?
Java return keyword is used to return from a method when its execution is complete . A Java keyword used to finish the execution of a method . It can be followed by a value required by the method definition .
What is short Keyword in Java ?
Java short keyword is used to declare a variable that can hold a 16-bit integer . A Java keyword used to define a variable of type short .
What is static Keyword in Java ?
Java static 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 . A Java keyword used to define a variable as a class variable . Classes maintain one copy of class variables regardless of how many instances exist of that class . static can also be used to define a method as a class method . Class methods are invoked by the class instead of a specific instance , and can only operate on class variables .
What is strictfp Keyword in Java ?
strictfp is a Java keyword used to restrict floating-point calculations to ensure portability . The modifier was introduced into the Java programming language with the Java virtual machine version 1.2 . Basically , what it all boils down to is whether or not you care that the results of floating-point expressions in your code are fast or predictable . For example , if you need the answers that your code comes up with which uses floating-point values to be consistent across multiple platforms then use strictfp .
What Does "strictfp" Do? , When this modifier is specified , the JVM sticks to the Java specifications and returns the consistent value independent of the platform . That is , if you want the answers from your code (which uses floating point values) to be consistent in all platforms , then you need to specify the strictfp modifier . Java's default class Math uses this strictfp modifier as shown below
public final strictfp class Math{ }
What is super Keyword in Java ?
Java super keyword is a reference variable that is used to refer parent class object . It can be used to invoke immediate parent class method . A Java keyword used to access members of a class inherited by the class in which it appears .
What is switch Keyword in Java ?
Java switch keyword contains a switch statement that executes code based on test value . The switch statement tests the equality of a variable against multiple values . A Java keyword used to evaluate a variable that can later be matched with a value specified by the case keyword in order to execute a group of statements .
What is synchronized Keyword in Java ?
Java synchronized keyword is used to specify the critical sections or methods in multithreaded code . If synchronized keyword applied to a method or code block , guarantees that at most one thread at a time executes that code .
What is this Keyword in Java ?
Java this keyword can be used to refer the current object in a method or constructor . It is used to represent an instance of the class in which it appears . this can be used to access class variables and methods .
What is throw Keyword in Java ?
The Java throw keyword is used to explicitly throw an exception . The throw keyword is mainly used to throw custom exception . It is used to throw an exception or any class that implements the " throwable " interface .
What is throws Keyword in Java ?
The Java throws keyword is used to declare an exception . Checked exception can be propagated with throws . It is used in method declarations that specify which exceptions are not handled within the method but rather passed to the next higher level of the program .
What is transient Keyword in Java ?
Java transient keyword is used in serialization . If you define any data member as transient , it will not be serialized . It indicates that a field is not part of the serialized form of an object . When an object is serialized , the values of its transient fields are not included in the serial representation , while the values of its non-transient fields are included .
What is try Keyword in Java ?
Java try 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 . A Java keyword that defines a block of statements that may throw a Java language exception . If an exception is thrown , an optional catch block can handle specific exceptions thrown within the try block . Also , an optional finally block will be executed regardless of whether an exception is thrown or not .
What is void Keyword in Java ?
Java void keyword is used to specify that a method does not have a return value . It is used in method declarations to specify that the method does not return any value . void can also be used as a nonfunctional statement .
What is volatile Keyword in Java ?
Java volatile keyword is used in variable declarations that specifies that the variable is modified asynchronously by concurrently running threads .
What is while Keyword in Java ?
Java 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 . A Java keyword used to declare a loop that iterates a block of statements . The loop's exit condition is specified as part of the while statement .
What is true Keyword in Java ?
A boolean literal value .
What is false Keyword in Java ?
A boolean literal value .
What is null Keyword in Java ?
Java null keyword is used to indicate that a reference does not refer to anything . It removes the garbage value . A reference literal value .
What is var Keyword in Java ?
A special identifier that cannot be used as a type name ( since Java 10 ) .