如何在java中设置对象的二维数组的值。
下面是我的for循环:
Object[][] hexgenSecurityInferenceData = null;
for (String methodName: knowGoodMap.keySet()) {
hexgenSecurityInferenceData = new Object[][] {
{
(KnownGoodInfoRO) knowGoodMap.get(methodName), new Object[] {
(MethodPropertiesRO) methodPropertiesMap.get(methodName), (List) methodParametersMap.get(methodName)
}
},
};
}这只打印一行数据。我确信我在adding values to Array of Object but really don't know how to fix.的时候犯了错
请帮我解决这个问题
发布于 2013-05-15 13:54:29
你有一个对象矩阵Object[][],所以如果你想填充这个二维数组,你必须这样做:
Object[][] hexgenSecurityInferenceData=new Object[10][10];
for(int i=0; i<10;i++){
for(int j=0; j<10;j++){
hexgenSecurityInferenceData[i][j] = new Object();
}
}Jon指出,和一样,最好有自己的实现/封装,而不是使用Object
https://stackoverflow.com/questions/16557765
复制相似问题