首页 > 代码库 > Cannot instantiate the type Map<String,Boolean>

Cannot instantiate the type Map<String,Boolean>

无法实例化类型Map<String,Boolean>

错误代码:

Map<String, Boolean> modelPropertys = new Map<String, Boolean>();

看了一下Map的定义,public abstract interface java.util.Map

原来是抽象接口,不能直接实例化,需要使用它的实现类;

正确写法如下:

Map<String, Boolean> modelPropertys = new HashMap<String, Boolean>();


Cannot instantiate the type Map<String,Boolean>