MarketList of Java keywords
Company Profile

List of Java keywords

In the Java programming language, a keyword is any one of 68 reserved words that have a predefined meaning in the language. Because of this, programmers cannot use keywords in some contexts, such as names for variables, methods, classes, or as any other identifier. Of these 68 keywords, 17 of them are only contextually reserved, and can sometimes be used as an identifier, unlike standard reserved words. Due to their special functions in the language, most integrated development environments for Java use syntax highlighting to display keywords in a different colour for easy identification.

Reserved keywords
The following words are reserved keywords and cannot be used as identifiers under any circumstances. ;_ :Added in Java 9, the underscore has become a keyword and cannot be used as a variable name anymore. ;abstract : A method with no definition must be declared as abstract and the class containing it must be declared as abstract. Abstract classes cannot be instantiated. Abstract methods must be implemented in the sub classes. The abstract keyword cannot be used with variables or constructors. Note that an abstract class isn't required to have an abstract method at all. ;assert (added in J2SE 1.4) :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. Assertions are disabled at runtime by default, but can be enabled through a command-line option or programmatically through a method on the class loader. : ;boolean :Defines a boolean variable for the values "true" or "false" only. By default, the value of boolean primitive type is false. This keyword is also used to declare that a method returns a value of the primitive type boolean. In most other languages, the Boolean type is usually simply called bool. ;break :Used to end the execution in the current loop body. :Used to break out of a switch block. ;byte :The byte keyword is used to declare a field that can hold an 8-bit signed two's complement integer. Alternatively, the default keyword can also be used to declare default values in a Java annotation. From Java 8 onwards, the default keyword can be used to allow an interface to provide an implementation of a method. ;do :The do keyword is used in conjunction with while to create a do-while loop, which executes a block of statements associated with the loop and then tests a boolean expression associated with the while. If the expression evaluates to true, the block is executed again; this continues until the expression evaluates to false. ;double :The double keyword is used to declare a variable that can hold a 64-bit double precision IEEE 754 floating-point number. This keyword is also used to declare that a method returns a value of the primitive type double. ;else :The else keyword is used in conjunction with if to create an if-else statement, which tests a boolean expression; if the expression evaluates to true, the block of statements associated with the if are evaluated; if it evaluates to false, the block of statements associated with the else are evaluated. ;enum (added in J2SE 5.0) :As of J2SE 5.0, the for keyword can also be used to create a so-called "enhanced for loop", which specifies an array or object; each iteration of the loop executes the associated block of statements using a different element in the array or Iterable. ;instanceof :A binary operator that takes an object reference as its first operand and a class or interface as its second operand and produces a boolean result. The instanceof operator evaluates to true if and only if the runtime type of the object is assignment compatible with the class or interface. ;int :The int keyword is used to declare a variable that can hold a 32-bit signed two's complement integer. ;protected :The protected keyword is used in the declaration of a method, field, or inner class; protected members can only be accessed by members of their own class, that class's subclasses or classes from the same package. ;super :Inheritance basically used to achieve dynamic binding or run-time polymorphism in Java. Used to access members of a class inherited by the class in which it appears. Allows a subclass to access overridden methods and hidden members of its superclass. The super keyword is also used to forward a call from a constructor to a constructor in the superclass. :Also used to specify a lower bound on a type parameter in Generics. ;switch :The switch keyword is used in conjunction with case and default to create a switch statement, which evaluates a variable, matches its value to a specific case (including patterns), and executes the block of statements associated with that case. If no case matches the value, the optional block labelled by default is executed, if included. ;try :Defines a block of statements that have exception handling. If an exception is thrown inside the try block, an optional catch block can handle declared exception types. Also, an optional finally block can be declared that will be executed when execution exits the try block and catch clauses, regardless of whether an exception is thrown or not. A try block must have at least one catch clause or a finally block. ;void :The void keyword is used to declare that a method does not return any value. Methods, classes and interfaces thus cannot be declared volatile, nor can local variables or parameters. ;while :The while keyword is used to create a while loop, which tests a boolean expression and executes the block of statements associated with the loop if the expression evaluates to true; this continues until the expression evaluates to false. This keyword can also be used to create a do-while loop; see do. Previously this keyword was used to restrict the precision and rounding of floating point calculations to ensure portability. ==Contextual keywords==
Contextual keywords
The following identifiers are contextual keywords, and are only restricted in some contexts: ;exports :Used in a module declaration to specify which packages are available to other modules. ;module :Declares a module (a collection of related packages and resources that can be treated as a unit), used to encapsulate and expose only the public API of a library. ;non-sealed :Used to declare that a class or interface which extends a sealed class can be extended by unknown classes. ;open :Indicates that all classes in a package are accessible via reflection by other modules. ;opens :Used to open a specific package for reflection to other modules. ;permits :The permits clause specifies the classes that are permitted to extend a sealed class. Used to declare a variable without explicitly specifying the type, rather relying on the compiler to infer the type based on the initialiser. ;when :Used as an additional check for a case statement. ;with :Used with the provides directive to specify which implementation of a service is provided by the module. ;yield :Used to set a value for a switch expression, when using labelled statement groups (for example, case L:). ==Reserved words for literal values==
Reserved words for literal values
The following words refer to literal values used by the language. ;true :A boolean literal value. ;false :A boolean literal value. ;null :A reference literal value. ==See also==
tickerdossier.comtickerdossier.substack.com