Flash cards
Review the key moves
1/4
Core idea
What is the main idea behind Java catch 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 catch keyword catches exceptions generated by try statements.
Definition and Usage
Java catch Keyword
❮ Java Keywords
Example
try {
int[] myNumbers = {1, 2, 3};
System.out.println(myNumbers[10]);
} catch (Exception e) {
System.out.println("Something went wrong.");
}Definition and Usage
The catch keyword catches exceptions generated by try statements.
The catch statement allows you to define a block of code to be executed, if an error occurs in the try block.
Related Pages
Read more about exceptions in our Java Try..Catch Tutorial .
❮ Java Keywords