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
}