The reserved keywords of the Java Language

throw

This instruction throw a new exception. The class of the exception must be in the hierarchy of Throwable. When an exception is launched, we go to the calling method or to the bouding catch block if there is one.

if(error)throw new Exception("There is an error");

throws

This keyword is used int the declaration of methods to indicate that this one can throw exceptions who are not caught.

public void read throws IOException {
	//Code that can throws an IOException
}

transient

This keyword enable to say than a field must not saved during the serialization of the class.

protected transient int variable = 2;

true

This keyword is a value of the boolean type, it’s the opposite of false.

boolean variable = true;

try

This keyword introduce an instruction block. It doesn’t have any other utility than allow the use of a catch and/or finally block.

try{
	//Instruction
} finally {
	//Instructions
}

void

This keyword declare a method with no return type. This method returns nothing.

public void methodThatReturnsNothing(){
	//Instructions diverses
}

volatile

We use this keyword on fields to force the VM to refresh it’s value at each use. With that we are sure to tuse the real value and not the cached value. This is only useful in concurrent programming.

public volatile int var = 5;

while

This last keyword introduce a while loop. This loop will iterate while the condition is verified (true). The condition is verified before entering the loop, so it’s possible to not enter in the loop if the condition is the condition is not verified.

while(condition){
	//Instructions
}

Related posts:

  1. Java Concurrency – Part 3 : Synchronization with intrinsic locks
  2. Introduction to JR programming language
  3. JR Operations and Capabilities
  4. Tip : Add resources dynamically to a ClassLoader
  5. Better exception handling in Java 7 : Multicatch and final rethrow

Pages: 1 2 3 4 5

  • http://www.monitorlcd17.org Monitor LCD 17

    a very good article with examples.