brianway / brianway/java-learning
关于在泛型笔记的问题
- Lingua principale
- Java
- Stelle
- 4.3k
- Fork
- 1.2k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
```
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,做了类型限制,这样代码更加灵活,出错率低。
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- java
- Ambito
- documentation
- Tipo di issue
- Documentazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100