# finally Block

A block that normally runs after try and catch whether an exception occurred or not.

## What is **finally Block** in Java?

**finally Block** — A block that normally runs after try and catch whether an exception occurred or not.

```java
class OrderReader {
    int readQuantity(String text) {
        try {
            return Integer.parseInt(text);
        } catch (NumberFormatException error) {
            return 0;
        } finally {
            closeReader();
        }
    }

    void closeReader() {
    }
}
```

Level: Journeyman · [More Java terms at this level](https://www.ask-codey.com/glossary/subjects/java/journeyman)

Updated: September 27, 2026

## In other subjects

- [finally Block in C#](https://www.ask-codey.com/glossary/finally-block-c-sharp)
- [finally Block in JavaScript](https://www.ask-codey.com/glossary/finally-block-javascript)

Source: https://www.ask-codey.com/glossary/finally-block
