brianway / brianway/java-learning
关于在泛型笔记的问题
- Lenguaje dominante
- Java
- Estrellas
- 4.3k
- Forks
- 1.2k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
```
int a = biggerOne(3,5);
//int 和 double,取交为Number
Number b = biggerOne(3,5.5);
System.out.println(b.getClass().getName());
//String和int 取交为Object
Object c = biggerOne("1",2);``
```
关于为什么b是Double类型的猜测。
这应该是多态,类如Number b = new Double();
而为什么将Number改为Double报错,应该是因为泛型T可能的值有两个int和double,做了类型限制,这样代码更加灵活,出错率低。
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Locate the definition of biggerOne and the surrounding Java generics notes or examples. Compare the calls using int, double, and String arguments, then verify the documented explanation against the observed return types. Done means the question is answered clearly in the relevant learning material, with any needed example or clarification included.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- java
- Área
- documentation
- Tipo de issue
- Documentación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100