Java Keywords
An (incomplete) list of the keywords in the Java language.
-
Java Keyword: this
The 'this' keyword can be used in two ways in a Java program: 1) As a reference to the current object, and 2) To call a different constructor
-
Java Keyword: catch
The Java keyword 'catch' is explained. The keyword is used to catch an exception and follows immediately after a try block.
-
Java Keyword: finally
The 'finally' keyword is used to open a block of code that executes after the preceeding try block. A finally block is often used to restore state, for instance by releasing resources aquired in a try block.
-
Java Keyword: throw
The Java keyword 'throw' is explained. The keyword is used to throw an exception. 'throw' followed by an expression of type Throwable forms a statement.
-
Java Keyword: throws
The Java keyword 'throws' is explained. The keyword is used in method declarations to indicate what exceptions may be thrown by calling the method.
-
Java Keyword: try
The 'try' keyword is used to open a block of code that potentially throw exceptions. A try block is followed by one or more catch blocks to catch any exceptions thrown.