|
1 | 1 | package effectivejava.chapter10.item74; |
2 | 2 |
|
| 3 | +// 실패 상황을 온전히 포착하도록 수정해본 IndexOutOfBoundsException (405쪽) |
3 | 4 | public class IndexOutOfBoundsException extends RuntimeException { |
4 | 5 | private final int lowerBound; |
5 | 6 | private final int upperBound; |
6 | 7 | private final int index; |
7 | 8 |
|
8 | 9 | /** |
9 | | - * Constructs an IndexOutOfBoundsException. |
| 10 | + * IndexOutOfBoundsException을 생성한다. |
10 | 11 | * |
11 | | - * @param lowerBound the lowest legal index value |
12 | | - * @param upperBound the highest legal index value plus one |
13 | | - * @param index the actual index value |
| 12 | + * @param lowerBound 인덱스의 최솟값 |
| 13 | + * @param upperBound 인덱스의 최댓값 + 1 |
| 14 | + * @param index 인덱스의 실젯값 |
14 | 15 | */ |
15 | 16 | public IndexOutOfBoundsException(int lowerBound, int upperBound, |
16 | 17 | int index) { |
17 | | - // Generate a detail message that captures the failure |
| 18 | + // 실패를 포착하는 상세 메시지를 생성한다. |
18 | 19 | super(String.format( |
19 | | - "Lower bound: %d, Upper bound: %d, Index: %d", |
| 20 | + "최솟값: %d, 최댓값: %d, 인덱스: %d", |
20 | 21 | lowerBound, upperBound, index)); |
21 | 22 |
|
22 | | - // Save failure information for programmatic access |
| 23 | + // 프로그램에서 이용할 수 있도록 실패 정보를 저장해둔다. |
23 | 24 | this.lowerBound = lowerBound; |
24 | 25 | this.upperBound = upperBound; |
25 | 26 | this.index = index; |
|
0 commit comments