Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit 24286e9

Browse files
authored
한글화
1 parent 11de7a5 commit 24286e9

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

src/effectivejava/chapter9/item65/ReflectiveInstantiation.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,42 @@
55
import java.util.Arrays;
66
import java.util.Set;
77

8-
// Reflective instantiaion demo (Page 283)
8+
// 리플렉션으로 활용한 인스턴스화 데모
99
public class ReflectiveInstantiation {
10-
// Reflective instantiation with interface access
10+
// 코드 65-1 리플렉션으로 생성하고 인터페이스로 참조해 활용한다. (372-373쪽)
1111
public static void main(String[] args) {
12-
// Translate the class name into a Class object
12+
// 클래스 이름을 Class 객체로 변환
1313
Class<? extends Set<String>> cl = null;
1414
try {
15-
cl = (Class<? extends Set<String>>) // Unchecked cast!
15+
cl = (Class<? extends Set<String>>) // 비검사 형변환!
1616
Class.forName(args[0]);
1717
} catch (ClassNotFoundException e) {
18-
fatalError("Class not found.");
18+
fatalError("클래스를 찾을 수 없습니다.");
1919
}
2020

21-
// Get the constructor
21+
// 생성자를 얻는다.
2222
Constructor<? extends Set<String>> cons = null;
2323
try {
2424
cons = cl.getDeclaredConstructor();
2525
} catch (NoSuchMethodException e) {
26-
fatalError("No parameterless constructor");
26+
fatalError("매개변수 없는 생성자를 찾을 수 없습니다.");
2727
}
2828

29-
// Instantiate the set
29+
// 집합의 인스턴스를 만든다.
3030
Set<String> s = null;
3131
try {
3232
s = cons.newInstance();
3333
} catch (IllegalAccessException e) {
34-
fatalError("Constructor not accessible");
34+
fatalError("생성자에 접근할 수 없습니다.");
3535
} catch (InstantiationException e) {
36-
fatalError("Class not instantiable.");
36+
fatalError("클래스를 인스턴스화할 수 없습니다.");
3737
} catch (InvocationTargetException e) {
38-
fatalError("Constructor threw " + e.getCause());
38+
fatalError("생성자가 예외를 던졌습니다: " + e.getCause());
3939
} catch (ClassCastException e) {
40-
fatalError("Class doesn't implement Set");
40+
fatalError("Set을 구현하지 않은 클래스입니다.");
4141
}
4242

43-
// Exercise the set
43+
// 생성한 집합을 사용한다.
4444
s.addAll(Arrays.asList(args).subList(1, args.length));
4545
System.out.println(s);
4646
}

0 commit comments

Comments
 (0)