标签: java generics syntax java-6 diamond-operator
请问有人可以建议如何重写下面的代码,使其与JDK 1.6兼容吗?
private Map<SocketChannel, byte[]> dataTracking = new HashMap<>();
答案 0 :(得分:4)
Java 6不支持菱形运算符。您还必须将通用规范复制到new调用中:
new
private Map<SocketChannel, byte[]> dataTracking = new HashMap<SocketChannel, byte[]>();