bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java finally Keyword

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind Java finally Keyword?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

___[] myNumbers = {1, 2, 3};
3Order

Put the learning moves in the order that makes the concept easiest to apply.

The finally keyword is used to execute code (used with exceptions - try.
Definition and Usage
Java finally Keyword

❮ Java Keywords

Example

try {
  int[] myNumbers = {1, 2, 3};
  System.out.println(myNumbers[10]);
} catch (Exception e) {
System.out.println("Something went wrong.");
} finally {
System.out.println("The 'try catch' is finished.");
}

Definition and Usage

The finally keyword is used to execute code (used with exceptions - try..catch statements) no matter if there is an exception or not.

Related Pages

Read more about exceptions in our Java Try..Catch Tutorial .

❮ Java Keywords

Previous

Java final Keyword

Next

Java float Keyword