Keywords or 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.
Java also contains a list of reserved words or keywords. These are:
- abstract -Specifies that a class or method will be implemented later, in a subclass
- assert -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.
- boolean – A data type that can hold True and False values only
- break – A control statement for breaking out of loops
- byte – A data type that can hold 8-bit data values
- case – Used in switch statements to mark blocks of text
- catch – Catches exceptions generated by try statements
- char – A data type that can hold unsigned 16-bit Unicode characters
- class -Declares a new class
- continue -Sends control back outside a loop
- default -Specifies the default block of code in a switch statement
- do -Starts a do-while loop
- double – A data type that can hold 64-bit floating-point numbers
- else – Indicates alternative branches in an if statement
- enum – A Java keyword used to declare an enumerated type. Enumerations extend the base class.
- extends -Indicates that a class is derived from another class or interface
- final -Indicates that a variable holds a constant value or that a method will not be overridden
- finally -Indicates a block of code in a try-catch structure that will always be executed
- float -A data type that holds a 32-bit floating-point number
- for -Used to start a for loop
- if -Tests a true/false expression and branches accordingly
- implements -Specifies that a class implements an interface
- import -References other classes
- instanceof -Indicates whether an object is an instance of a specific class or implements an interface
- int – A data type that can hold a 32-bit signed integer
- interface – Declares an interface
- long – A data type that holds a 64-bit integer
- native -Specifies that a method is implemented with native (platform-specific) code
- new – Creates new objects
- null -Indicates that a reference does not refer to anything
- package – Declares a Java package
- private -An access specifier indicating that a method or variable may be accessed only in the class it’s declared in
- protected – An access specifier indicating that a method or variable may only be accessed in the class it’s declared in (or a subclass of the class it’s declared in or other classes in the same package)
- public – An access specifier used for classes, interfaces, methods, and variables indicating that an item is accessible throughout the application (or where the class that defines it is accessible)
- return -Sends control and possibly a return value back from a called method
- short – A data type that can hold a 16-bit integer
- static -Indicates that a variable or method is a class method (rather than being limited to one particular object)
- strictfp – A Java keyword used to restrict the precision and rounding of floating point calculations to ensure portability.
- super – Refers to a class’s base class (used in a method or class constructor)
- switch -A statement that executes code based on a test value
- synchronized -Specifies critical sections or methods in multithreaded code
- this -Refers to the current object in a method or constructor
- throw – Creates an exception
- throws -Indicates what exceptions may be thrown by a method
- transient -Specifies that a variable is not part of an object’s persistent state
- try -Starts a block of code that will be tested for exceptions
- void -Specifies that a method does not have a return value
- volatile -Indicates that a variable may change asynchronously
- while -Starts a while loop
** The keywords const and goto are reserved, even they are not currently in use.
- const -Reserved for future use
- goto – Reserved for future use
** true, false and null look like keywords, but in actual they are literals. However they still can’t be used as identifiers in a program.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- super and this keywords in Java
- Important Keywords in Java
- Program to convert List of Integer to List of String in Java
- Program to convert List of String to List of Integer in Java
- How to iterate over a 2D list (list of lists) in Java
- List to Set in Java
- Min and Max in a List in Java
- Set to List in Java
- List to array in Java
- Immutable List in Java
- Initializing a List in Java
- How to Clone a List in Java?
- Convert List to Set in Java
- List contains() method in Java with Examples
- Program to Convert Set to List in Java
- Conversion of Java Maps to List
- List get() method in Java with Examples
- List Interface in Java with Examples
- Difference between List and ArrayList in Java
- Convert an Iterator to a List in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.