0
点赞
收藏
分享

微信扫一扫

Java 泛型中的类型推断

Mhhao 2022-06-10 阅读 72

这样写,编译器报错:

jshell> List<?> unknows = new ArrayList<?>()
| Error:
| unexpected type
| required: class or interface without bounds
| found: ?
| List<?> unknows = new ArrayList<?>();
| ^----------^

可以这样写:

jshell> List<?> unknows = new ArrayList<String>()
unknows ==> []



举报

相关推荐

0 条评论