为什么Java中的泛型使用类而不是基本类型?
例如,这工作正常:
List<Integer> foo = new ArrayList<Integer>();
Run Code Online (Sandbox Code Playgroud)
但这是不允许的:
List<int> bar = new ArrayList<int>();
Run Code Online (Sandbox Code Playgroud) 我正在使用代码:
System.out.println(null);
Run Code Online (Sandbox Code Playgroud)
它显示错误:
The method println(char[]) is ambiguous for the type PrintStream
Run Code Online (Sandbox Code Playgroud)
为什么没有null代表Object?