List of keywords and their usages in Java Programming language. To learn more about a specific keyword, just click on the keyword and it will take you to a separate keyword tutorial where you can find examples and more details about that particular keyword.
Keyword | Description |
abstract | Used for classes and methods. An abstract class cannot be instantiated, which means you cannot create an object of this class, it can be used through inheritance in sub class. An abstract method does not have a body and can only be declared inside abstract class, the method is overriden in sub class, where it can have a body. |
boolean | It is a data type, which is used to declare a variable. A boolean variable can hold only true or false values. A boolean keyword can also be used be as a return type of a method. |
break | The break keyword is used to end the execution of the loops such as for, while, do-while, it can also be used inside a switch block to form switch-case. It is generally accompanied by a condition inside a loop, when the condition is meet, the break statement is encountered and it ends the loop. |
byte | The byte keyword is a data type. It can hold values in the range of -128 to 127. |
case | It is used along with switch statement to form a switch-case block, this switch case block is used to evaluate a given condition and execute corresponding block based on the output of condition. |
catch | Used with try block to handle an exception. |
char | It is a primitive data type. It is used to store a single character. Size is 2 bytes and it can print characters for ASCII values between 0 and 65,535. |
class | The class keyword is used to create a class. |
continue | The continue statement is used inside a loop to directly jump to the next iteration of the loop, skipping the statements after continue statement for this iteration. |
default | Used inside switch block. It specifies the default case in switch, which executes when there is no matching case block is found. |
do | Used in do-while loop. The do-while loop checks the loop condition after the first execution of the loop body so it executes at-least once for any condition. |
double | It is a primitive data type. The range is 1.7e-308 to 1.7e+308 . |
else | It is used along with if for if-else conditional statement. |
enum | The enum keyword is used to define a set of constants. |
extends | It is used in inheritance, where sub class can access the methods and variables of the parent class. |
final | It is used with class, variables and methods. It marks them final (non-changeable). |
finally | The finally keyword used in exception handling. The finally block always executes whether an exception occurs or not. |
float | A primitive data type used for floating point numbers. The range is 3.4e-038 to 3.4e+038 . |
for | The for keyword is used for creating a for loop. |
if | If statement checks a condition and executes statements inside if body, only when the condition returns true. |
implements | It is used for implementing an interface. |
import | The import keyword is used for importing a package. |
instanceof | It checks if the object is an instance of the given class or interface. |
int | A primitive data type for whole numbers. The range is -2147483648 to 2147483647 . |
interface | Used to create an interface that contains abstract methods (method without body), these methods are given body in sub class using method overriding. |
long | A primitive data type, which is used for storing whole numbers. It has a bigger range than int data type. The range of long is -9223372036854775808 to 9223372036854775808 . |
native | It specifies that method is implemented in native code and not included in the java source code file. |
new | It is used for creating new objects of classes. |
null | It specifies that object does not refer to anything in the memory. |
package | Used for creating packages. These packages contain classes. Similar types of classes are included in same package. This helps in grouping the classes in a meaningful manner. |
private | The private keyword is used for variables, methods and constructors. It is the most restrictive access modifier, which makes them only accessible within the class. |
protected | It is used for variables, methods and constructors. It makes them accessible within the same package and in the subclasses only. |
public | It is the least restrictive access modifier. It is used for classes, methods, variables and constructors. It makes them accessible by any class. |
return | Used by a method to return a value. |
short | A primitive data type, which is used for storing whole numbers but the range is shorter than int. The range of short data type is: -32768 to 32767 . |
static | The static keyword is used for variables and methods. Such methods and variables can be accessed without creating the object of the class. |
strictfp | Used for floating point numbers portability. The precision is system dependent so strictfp restricts the precision and rounding of floating point numbers. |
super | Refers to the parent class object. |
switch | Conditional statement, that evaluates a given condition and executes the corresponding case block. |
synchronized | It is used to control multithreading. It specifies that a method can be only accessed by one thread at a time. |
this | Refers to the object of current class. |
throw | It is used to throw exception explicitly. |
throws | It is used to declare an exception. Mainly used for checked exceptions. |
transient | The transient keyword is used in serialization. |
try | It is used in exception handling. The set of statements that can throw an exception are placed inside try block. |
void | Specifies that a method does not return anything. |
volatile | Specifies that a variable is accessed directly from main memory and may be changed asynchronously. |
while | The while keyword is used to create a while loop. |