Keywords also are known as reserved words are the pre-defined identifiers reserved by Java for a specific purpose that inform the compiler about what the program should do. A Keyword is that which have a special meaning those already explained to the java language like int, float, class, public, etc. these are the reserved keywords. These special words cannot be used as class names, variables, or method names, because they have special meaning within the language.
Always remember that we can t give a name to a variable as the name of a keyword. Java provides us the 60 keywords. All the keywords are to be written into the lower case because java is a case sensitive means, upper case, and lower case letters are different in java. Some keywords inherited by the java language from C and C++; it adds only 27 keywords like the system, interface, abstract, final, etc.
In addition to the keywords in the table, there are more reserved words in Java: true, false and null. Technically they are literal values and not keywords. However, they cannot use as an identifier, and they have a special meaning to the Java compiler.
Java Keywords
• abstract: To declare a class abstract, use the abstract keyword in front of the class keyword at the beginning of the class declaration.
• boolean: In Java, the boolean type is represented using a boolean keyword. The boolean data type can only hold two values: true and false.
• break: Java break keyword place at the end of each case statement. It means that when the keyword break encountered, the switch block exit, ignoring any other cases.
• byte: Java Keyword “byte is a data type that can hold an 8-bit signed integer primitive type which ranges from -128 to 127.
• case: Java keyword “case” is used with switch keyword to mark blocks of text.
• catch: Java keyword ‘catch’ is used to catch an exception generated by try statements. It must use after the try block only.
• char: Java char keyword is a data type that can store unsigned 16-bit Unicode characters.
• class: Class is a keyword used for declaring the class.
• continue: Java continue keyword use in any of the loop control structures. The continue keyword is used to jump to the next iteration of the loop.
• default: Java default keyword can also be used to specify the default values in a switch statement.
• do: Java do keyword is used together with while to declare a do-while looping block.
• double: Java double keyword use as a data type that can hold double-precision 64-bit floating-point numbers.
• else: Java else keyword is always used to indicate the alternative block of Java code with the if the keyword in an if-else statement.
• enum: Java enum keyword is used to declares an enumerated (unchangeable) type. It is a special data type that represents a group of predefined constants.
• extends: An interface can be interfaced from other interfaces, using the keyword extends.
• final: Java final keyword is a non-access modifier that a variable holds a constant value. It applies along with a variable, a method or a class.
• finally: Java finally keyword is used in association with a try-catch structure. This block of code always executed, whether an exception thrown. It can’t use as an identifier.
• float: Java float keyword is a primitive data type that can hold a double−precision 32-bit floating point value.
• for: Java for keyword is a control structure that is used to start a looping statement that is for a loop. It is used to executes a block of code multiple times.
• if: Java if keyword is the most basic of all decision-making statement. It executes a certain section of code only if the condition is true.
• implements: Java implements keyword is used to declare an interface.
• import: Java import keyword is used to import built-in and user-defined packages to the current source code.
• instanceof: Java instanceof keyword can be used to test if an object is an instance of the specified class or implements an interface.
• int: Java int keyword is a data type that can hold a 32 bit signed primitive integer type.
• interface: To create an interface, we use the keyword interface.
• long: Java long keyword is a data type that can hold a 64-bit integer number which ranges from -263 to 263 – 1.
• native: Java native keyword can be applied to a method to implement in native code using JNI (Java Native Interface).
• new: Java Instance variables constructed when the keyword “new” use in creating an object
• null: The null value is not a keyword in java. It is a reserved word in java language.
• package: In java package is a keyword used to encapsulate the class file. A collection of classes is called a package.
• private: Java private keyword, which declares a member’s access as private that can apply to a method, member variable, and an inner class.
• protected: Java protected keyword is an access modifier used for the method and variable of a class. It can be accessible in the same package and subclasses.
• public: Public is an access modifier keyword that commands compiler access to the class. The public keyword gives information about visibility.
• return: The return keyword itself does two things. The first thing is to send back to the method call.The next thing the return keyword does is marks the completion of the method.
• short: Java short keyword is a data type that can hold a 16-bit signed two’s complement integer.
• static: Java Class or static variables are declared using the keyword static in a class. This, however, is outside a block, method, or constructor.
• strictfp: Java strictfp keyword use for restricting floating-point calculations to ensure portability.
• super: Java super keyword allows you to reference fields, constructors and methods of the direct parent (class after the “extends” keyword) class.
• switch: Java switch keyword is a multi-way branch statement that executes one statement from multiple conditions.
• synchronized: Java synchronized keyword is a way to mark the place where a thread needs to acquire a key to the lock to use an object.
• this: Java this keyword can be used to reference a variable that refers to the current object in a method or constructor.
• throw: Java throw keyword is used to explicitly throw an exception from a method or any block of code.
• throws: Java throws keyword is used to throw an exception explicitly. The throw keyword must be in the try block.
• transient: Java transient keyword is used in class to indicate that serialization. Its value isn’t stored permanently.
• try: Java try keyword is used to define a block of code to test for errors. A try block must be followed by a catch block or finally block, which handles the exception that occurs in the associated try block.
• void: Java void keyword specifies that a method does not have a return type.
• volatile: Java volatile keyword is used to indicate that a Java variable as “being stored in main memory.”
• while: Java while keyword is used to repeat a specific block of code. This loop iterates a block of statements continuously until the given condition is true.