Skip to content

Commit 32b5603

Browse files
committed
编译期 -> 编译器 ,原文"the compiler will only allow you to say that the superclass reference is “some class that is a superclass of FancyToy” a"
1 parent cfa16be commit 32b5603

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/book/19-Type-Information.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ public class GenericToyTest {
527527
}
528528
```
529529

530-
如果你手头的是超类,那编译期将只允许你声明超类引用为“某个类,它是 `FancyToy` 的超类”,就像在表达式 `Class<? super FancyToy>` 中所看到的那样。而不会接收 `Class<Toy>` 这样的声明。这看上去显得有些怪,因为 `getSuperClass()` 方法返回的是基类(不是接口),并且编译器在编译期就知道它是什么类型了(在本例中就是 `Toy.class`),而不仅仅只是"某个类"。不管怎样,正是由于这种含糊性,`up.newInstance` 的返回值不是精确类型,而只是 `Object`
530+
如果你手头的是超类,那编译器将只允许你声明超类引用为“某个类,它是 `FancyToy` 的超类”,就像在表达式 `Class<? super FancyToy>` 中所看到的那样。而不会接收 `Class<Toy>` 这样的声明。这看上去显得有些怪,因为 `getSuperClass()` 方法返回的是基类(不是接口),并且编译器在编译期就知道它是什么类型了(在本例中就是 `Toy.class`),而不仅仅只是"某个类"。不管怎样,正是由于这种含糊性,`up.newInstance` 的返回值不是精确类型,而只是 `Object`
531531

532532
### `cast()` 方法
533533

0 commit comments

Comments
 (0)