Java Keywords List Definition Usage

Java Keywords List Definition Usage
Java Keywords List Definition Usage


Keywords in Java: A Java word is a pre-defined in the library is called keyword. It's functionality is also pre-defined. Java keywords can not be used as a variable, function name, class name or as an any identifier. Keywords are int, float, char, void, main. Total 52 reserved keywords in java.

Reserved Keywords in Java

char continue double else
default catch finally final
long interface int instanceof
assert abstract class extends
implements const float boolean
private public protected package
break byte case do
enum for goto if
import empact new return
strictfp synchronized static show
super switch this throw
throws transient try


List of Java Keywords and Their Uses

char keyword: A char keyword is a primitive data type it can be used to store a single Unicode character.

It can be used 2 bytes memory and character(char) can be store letters, digits, or special symbols in a single quote.

Example of Char Keyword in Java

class Jiocoding{
public static void main(String[] args) {
char c='J';
System.out.println("Character Keyword:"+c);
}
}

============OUTPUT============
Character Keyword: J

continue Keyword: A continue keyword is a jump statement in Java that skips the current iteration of a loop and moves directly to the next iteration.

Example of Continue Keyword in Java

class Jiocoding{
public static void main(String[] args) {
for(int i=0;i<=5;i++){
if(i==3){
continue;
}
System.out.println(Continue Keyword:"+);
}
}
}
}

============OUTPUT============
Continue Keyword:1
Continue Keyword:2
Continue Keyword:4
Continue Keyword:5

finally Keyword: Finally keyword is used to a block in java that always executes after a try and optional catch block, regardless of whether an exception occurs or not.


interface Keyword: Interface keyword can be used to declare an interface, which is a completely abstract type containing abstract methods, default methods, static methods, and constants.


public Keyword: Public keyword is an access modifier in Java that makes a class, method, or variable accessible from anywhere in the program, across all packages.


protected Keyword: Protected is an access modifier in Java that allows a variable to be accessed within the same package and also in subclasses.


private Keyword: Private is an access modifier in Java that restricts access to class variables so they can only be accessed within the same class.


import Keyword: A import keyword allows you to use classes from other packages without writing their full package name.


new Keyword: A new keyword is used to create objects in Java. It is allocate memory for an object.


this Keyword: A this keyword refers to the current class object the object calling the function.


super keyword: A super keyword is used to refer to the parent class. Super keyword access parent class or parent class constructor.


synchronized Keyword: A synchronized keyword can be used to control access to a block of code or a method by multiple threads. It ensures that only one thread at a time can execute the synchronized method.


assert Keyword: A assert keyword can be used for debugging and validating assumptions in code. It checks whether a condition is true. If the condition is false.


implements Keyword: A implements keyword is can be used by classes to implement an interface.


abstract Keyword: A abstract keyword can be used for classes and methods. method declared abstract has no body and must be implemented in a subclass.


Conclusion of Java Keywords

Conclusion: A Java Keywords is a reserve Keywords. It can not be used in variable names. This article cover most important keywords but same keywords are not covered in this article. If your any query for Java Keywords related you can contact me by email or comment.


Java Programming Language


Post a Comment

0 Comments