我正在从事一个项目,在该项目中,我在初始化具有特定大小的一种方法时遇到了 TypeSafety 问题。在我的运行方法中,我有黄线new ArrayList[tableLists.size()]
并抱怨 -
Type safety: The expression of type ArrayList[] needs unchecked conversion to conform to ArrayList<Method>[]
下面是代码。
private ArrayList<Method> methods[] = null;
@Override
public void run() {
methods = new ArrayList[tableLists.size()];
}
我怎样才能TypeSafety
在这里解决这个问题?
更新:-
int j = 0;
dbConnection = new Connection[tableLists.size()];
callableStatement = new CallableStatement[tableLists.size()];
methods = new ArrayList[tableLists.size()];
//loop around the map values and make the connection list
for (Map<String, String> map : tableLists.values()) {
dbConnection[j] = getDBConnection(map.get("URL"), map.get("USER"), map.get("PASSWORD"), map.get("DRIVER"));
callableStatement[j] = dbConnection[j].prepareCall(map.get("SQL"));
methods[j] = getRequiredMethods(map.get("SUFFIX"));
j++;
}