---
id: java-exceptions-multiple
title: "Java Exceptions Multiple"
category: "Programming_Language"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["multiple catch blocks", "multi-catch", "자바 다중 예외"]
duplicate_of: ""
source_trust_level: "B"
confidence_score: 0.9
created_at: 2026-07-04
updated_at: 2026-07-04
review_reason: ""
merge_history: []
tags: ["java", "programming", "w3schools", "exceptions", "multi-catch"]
raw_sources: ["https://www.w3schools.com/java/java_exceptions_multiple.asp"]
applied_in: []
github_commit: ""
---

# [[Java Exceptions Multiple]]

## 🎯 한 줄 통찰 (One-line insight)
Catch block order is not cosmetic — putting the general `Exception` catch BEFORE a specific `ArithmeticException` catch means the specific catch becomes unreachable dead code, since the general catch matches everything first; specific exceptions must always precede general ones. [S1]

## 🧠 핵심 개념 (Core concepts)
- **Multiple catch blocks** — one `try` can be followed by several `catch` blocks for different exception types. [S1]
- **First-match wins** — Java runs the FIRST catch block whose type matches the thrown exception; only one catch runs even if multiple errors would occur. [S1]
- **Ordering rule** — specific exceptions must come before general ones (`Exception` last), or the general catch silently swallows everything. [S1]
- **Multi-catch (`|`)** — since Java 7, catch several exception types in ONE block using `|`, avoiding duplicated handler code. [S1]

## 📖 세부 내용 (Details)
- Multiple catches, first match wins: `try { System.out.println(numbers[10]); int result = 10 / 0; } catch (ArrayIndexOutOfBoundsException e) { System.out.println("Array index does not exist."); } catch (ArithmeticException e) {...} catch (Exception e) {...}` — only the array exception fires since it happens first. [S1]
- Bad ordering (unreachable code): `catch (Exception e) {...} catch (ArithmeticException e) { /* never reached */ }`. [S1]
- Multi-catch with `|`: `catch (ArithmeticException | ArrayIndexOutOfBoundsException e) { System.out.println("Math error or array error occurred."); }`. [S1]

## ⚖️ 모순 및 업데이트 (Contradictions & updates)
- **catch 순서 규칙**: 일반적인 Exception을 먼저 두면 이후 구체적인 catch가 절대 도달하지 못한다는 점이 강하게 경고됨. [S1]

## 🛠️ 적용 사례 (Applied in summary)
현재 발견된 실제 적용 사례가 없습니다 — 같은 방식으로 처리할 여러 예외를 |로 묶는 multi-catch가 코드 중복을 줄이는 실전 패턴이다. [S1]

## 💻 코드 패턴 (Code patterns)
Multi-catch with the | symbol (Java, since Java 7):
```java
try {
    int result = 10 / 0;
    int[] numbers = {1, 2, 3};
    System.out.println(numbers[10]);
}
catch (ArithmeticException | ArrayIndexOutOfBoundsException e) {
    System.out.println("Math error or array error occurred.");
}
```

## ✅ 검증 상태 및 신뢰도
- **상태:** draft
- **검증 단계:** conceptual
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
- **신뢰 점수:** 0.90
- **중복 검사 결과:** 신규 생성 (New discovery)

## 🔗 지식 그래프 (Knowledge Graph)
- **상위/루트:** [[Java Tutorial]]
- **관련 개념:** [[Java Try Catch]], [[Java Try Catch Resources]]
- **참조 맥락:** 여러 예외 타입 처리 — try-with-resources 챕터로 이어짐.

## 📚 출처 (Sources)
- [S1] W3Schools — Java Multiple Exceptions — https://www.w3schools.com/java/java_exceptions_multiple.asp

## 📝 변경 이력 (Change history)
- 2026-07-04: Initial draft synthesized from the W3Schools "Java Multiple Exceptions" page (Astra wiki-curation, P-Reinforce v3.1 format).
