Keywords in Java

Keywords are the pre-defined words which convey special meaning to the compiler. These words have predefined meaning.
Example- 'class' keyword is used for creating class
There are 50 keywords in java.


Example of using java keywords -

//program for addition of two number
// 'class ' is keyword used for creatig the class
class Add
{
	public static void main(String[] args) {
		//'public,static,void 'also a keyword which convey specific meaning
		int a=5;
		int b=4;
		int c=a+b;
		System.out.println("Addition ="+c);
	}
}
Addition=9

Java 9 has some new module-related keywords.

These keywords are as follows

  It is important to understand that these keywords are recognized as keywords only in the context of a module declaration. Otherwise, they are interpreted as identifiers in other situations.

  Because they are context-sensitive, the module-related keywords are formally called Restricted keywords .

woman avatar