Java Keywords

Java has more than 50 keywords for the different operations. Here is the list of all the keywords and its purpose.

abstractAbstract keyword can be use with classes and methods to defer the actual implementation to the child classes.
assertThis keyword used for testing the truth of a condition.
booleanIndicates that a value is either true or false.
breakJumps out of a loop or switch block.
byteIndicates that a value is an 8-bit whole number.
caseThis is used in the switch block to define the different conditions using the case block.
catchThis is used with the exception handling. To catch the exception thrown from the above code will be handled.
charIndicates that a value is a character (a single letter, digit, punctuation symbol, and so on) stored in 16 bits of memory.
classUsed for declaring a class. A structure of an object for storing data and state.
constYou can’t use this word in a Java program. The word has no meaning. Because it’s a keyword, you can’t create a const variable.
continueForces the abrupt end of the current loop iteration and begins another iteration.
defaultIntroduces a path of execution to take when no case is a match in a switchstatement.
doCauses the computer to repeat some statements over and over again (for instance, as long as the computer keeps getting unacceptable results).
doubleIndicates that a value is a 64-bit number with one or more digits after the decimal point.
elseIntroduces statements that are executed when the condition in an if statement isn’t true.
enumCreates a newly defined type — a group of values that a variable can have.
extendsCreates a subclass — a class that reuses functionality from a previously defined class.
finalIndicates that a variable’s value cannot be changed, that a class’s functionality cannot be extended, or that a method cannot be overridden.
finallyIntroduces the last will and testament of the statements in a try clause.
floatIndicates that a value is a 32-bit number with one or more digits after the decimal point.
forGets the computer to repeat some statements over and over again (for instance, a certain number of times).
gotoYou can’t use this word in a Java program. The word has no meaning. Because it’s a keyword, you can’t create a goto variable.
ifSimple condition to enter a block.
implementsReuses the functionality from a previously defined interface.
importEnables the programmer to abbreviate the names of classes defined in a package.
instanceofTests to see whether a certain object comes from a certain class.
intIndicates that a value is a 32-bit whole number.
interfaceIntroduces an interface, which is like a class, but less specific. (Interfaces are used in place of the confusing multiple-inheritance feature that’s in C++.)
longIndicates that a value is a 64-bit whole number.
nativeEnables the programmer to use code that was written in another language (one of those awful languages other than Java).
newCreates an object from an existing class.
packagePuts the code into a package — a collection of logically related definitions.
privateIndicates that a variable or method can be used only within a certain class.
protectedIndicates that a variable or method can be used in subclasses from another package.
publicIndicates that a variable, class, or method can be used by any other Java code.
returnEnds execution of a method and possibly returns a value to the calling code.
shortIndicates that a value is a 16-bit whole number.
staticIt implies that the variable or method is bound to the class and not to the instance of that class.
strictfpLimits the computer’s ability to represent extra large or extra small numbers when the computer does intermediate calculations on float and double values.
superRefers to the superclass of the code in which the word super appears.
switchTells the computer to follow one of many possible paths of execution (one of many possible cases), depending on the value of an expression.
synchronizedTo lock a particular piece of code or method while one thread is executing.
thisA self-reference — refers to the object in which the word this appears.
throwCreates a new exception object and indicates that an exceptional situation (usually something unwanted) has occurred.
throwsIndicates that a method or constructor may pass the buck when an exception is thrown.
transientIndicates that, if and when an object is serialized, a variable’s value doesn’t need to be stored.
tryIntroduces statements that are watched (during runtime) for things that can go wrong.
voidIndicates that a method doesn’t return a value.
volatileImposes strict rules on the use of a variable by more than one thread at a time.
whileIt is a loop to iterate the list of values till it satisfy a condition.



About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.