Java Keywords

abstract

A Java keyword used in a class definition to specify that a class is not to be instantiated, but rather inherited by other classes. An abstract class can have abstract methods that are not implemented in the abstract class, but in subclasses.

abstract class

A class that contains one or more abstract methods, and therefore can never be instantiated. Abstract classes are defined so that other classes can extend them and make them concrete by implementing the abstract methods.

abstract method

A method that has no implementation.

assert

An assertion is a statement in the Java programming language that enables you to test your assumptions about your program.

boolean

Refers to an expression or variable that can have only a true or false value. The Java programming language provides the boolean type and the literal values true and false.

break

A Java keyword used to resume program execution at the statement immediately following the current statement. If followed by a label, the program resumes execution at the labeled statement.

byte

A sequence of eight bits. Java provides a corresponding byte type.

case

A Java keyword that defines a group of statements to begin executing if a value specified matches the value defined by a preceding switch keyword.

catch

A Java keyword used to declare a block of statements to be executed in the event that a Java exception, or run time error, occurs in a preceding try block.

class

In the Java programming language, a type that defines the implementation of a particular kind of object. A class definition defines instance and class variables and methods, as well as specifying the interfaces the class implements and the immediate superclass of the class. If the superclass is not explicitly specified, the superclass will implicitly be Object.

class method

A method that is invoked without reference to a particular object. Class methods affect the class as a whole, not a particular instance of the class. Also called a static method.

class variable

A data item associated with a particular class as a whole--not with particular instances of the class. Class variables are defined in class definitions. Also called a static field.

Classpath

An environmental variable which tells the Java Virtual Machine and Java technology-based applications where to find the class libraries, including user-defined class libraries.

const

A reserved Java keyword not used by current versions of the Java programming language.

continue

A Java keyword used to resume program execution at the end of the current loop. If followed by a label, continue resumes execution where the label occurs.

default

A Java keyword optionally used after all case conditions in a switch statement. If all case conditions are not matched by the value of the switch variable, the default keyword will be executed.

do

A Java keyword used to declare a loop that will iterate a block of statements. The loop's exit condition can be specified with the while keyword.

double

A Java keyword used to define a variable of type double.

double precision

In the Java programming language specification, describes a floating point number that holds 64 bits of data.

else

A Java keyword used to execute a block of statements in the case that the test condition with the if keyword evaluates to false.

enum

A Java keyword used to declare an enumerated type.

extends

extends is a Java keyword used to inherit the properties and methods of another class. class X extends class Y to add functionality, either by adding fields or methods to class Y, or by overriding methods of class Y. An interface extends another interface by adding methods. Class X is said to be a subclass of class Y.

final

If you declare class, method or field those are not modifiable at any point after declaration. A final class cannot be subclassed, a final method cannot be overridden and a final variable cannot change from its initialized value.

finally

A Java keyword that executes a block of statements regardless of whether a Java Exception, or run time error, occurred in a block defined previously by the try keyword.

float

A Java keyword used to define a floating point number variable.

for

A Java keyword used to declare a loop that reiterates statements. The programmer can specify the statements to be executed, exit conditions, and initialization variables for the loop.

goto

It is not used by current versions of the Java programming language.

if

A Java keyword used to conduct a conditional test and execute a block of statements if the test evaluates to true.

implements

A Java keyword included in the class declaration to specify any interfaces that are implemented by the current class.

import

A Java keyword used at the beginning of a source file that can specify classes or entire packages to be referred to later without including their package names in the reference.

instanceof

A two-argument Java keyword that tests whether the runtime type of its first argument is assignment compatible with its second argument.

int

A Java keyword used to define a variable of type integer.

interface

A Java keyword used to define a collection of method definitions and constant values. It can later be implemented by classes that define this interface with the "implements" keyword.

long

A Java keyword used to define a variable of type long.

native

A Java keyword that is used in method declarations to specify that the method is not implemented in the same Java source file, but rather in another language.

new

A Java keyword used to create an instance of a class.

package

A group of types. Packages are declared with the package keyword.

private

A Java keyword used in a method or variable declaration. It signifies that the method or variable can only be accessed by other elements of its class.

protected

A Java keyword used in a method or variable declaration. It signifies that the method or variable can only be accessed by elements residing in its class, subclasses, or classes in the same package.

public

A Java keyword used in a class, method or variable declaration. It signifies that the method or variable can be accessed by elements residing in other classes.

return

A Java keyword used to finish the execution of a method. It can be followed by a value required by the method definition.

short

A Java keyword used to define a variable of type short.

static

A Java keyword used to define a variable as a class variable. Classes maintain one copy of class variables regardless of how many instances exist of that class. static can also be used to define a method as a class method. Class methods are invoked by the class instead of a specific instance, and can only operate on class variables.

strictfp

strictfp is a Java keyword used to restrict floating-point calculations to ensure portability. The modifier was introduced into the Java programming language with the Java virtual machine version 1.2.

Basically, what it all boils down to is whether or not you care that the results of floating-point expressions in your code are fast or predictable. For example, if you need the answers that your code comes up with which uses floating-point values to be consistent across multiple platforms then use strictfp.

What Does "strictfp" Do?, When this modifier is specified, the JVM sticks to the Java specifications and returns the consistent value independent of the platform. That is, if you want the answers from your code (which uses floating point values) to be consistent in all platforms, then you need to specify the strictfp modifier.

Java's default class Math uses this strictfp modifier as shown below

public final strictfp class Math{ }

super

A Java keyword used to access members of a class inherited by the class in which it appears.

switch

A Java keyword used to evaluate a variable that can later be matched with a value specified by the case keyword in order to execute a group of statements.

synchronized

If synchronized keyword applied to a method or code block, guarantees that at most one thread at a time executes that code.

this

It is used to represent an instance of the class in which it appears. this can be used to access class variables and methods.

throw

It is used to throw an exception or any class that implements the "throwable" interface.

throws

It is used in method declarations that specify which exceptions are not handled within the method but rather passed to the next higher level of the program.

transient

It indicates that a field is not part of the serialized form of an object. When an object is serialized, the values of its transient fields are not included in the serial representation, while the values of its non-transient fields are included.

try

A Java keyword that defines a block of statements that may throw a Java language exception. If an exception is thrown, an optional catch block can handle specific exceptions thrown within the try block. Also, an optional finally block will be executed regardless of whether an exception is thrown or not.

void

It is used in method declarations to specify that the method does not return any value. void can also be used as a nonfunctional statement.

volatile

It is used in variable declarations that specifies that the variable is modified asynchronously by concurrently running threads.

while

A Java keyword used to declare a loop that iterates a block of statements. The loop's exit condition is specified as part of the while statement.