You can't add elements to an array - you can only set elements in an array.
I suggest you have a List<Object[]> instead:
List<Object[]> hexgenSecurityInferenceData = new ArrayList<Object[]>();
for (String methodName:knowGoodMap.keySet()) {
hexgenSecurityInferenceData.add(new Object[] {
knowGoodMap.get(methodName),
new Object[] {
methodPropertiesMap.get(methodName),
methodParametersMap.get(methodName)
}
});
}
(I've removed the casts as they were pointless... you're storing the values in an Object[] anyway. The only benefit of the casts would be to cause an exception if the objects were of an unexpected type.)
You could still use an array if you really wanted, but you'd need to create it with the right size to start with, and then keep the "current index". It's then generally harder to use arrays than lists anyway.
If you really need an array, you can create one from the list:
Object[][] array = hexgenSecurityInferenceData.toArray(new Object[0][]);
Doing it in two stages this way will be simpler than directly populating an array up-front.
I'd actually suggest two further changes:
- Don't just use
Object[] for this... create a type to encapsulate this data. With your current approach, you've even got a nested Object[] within the Object[]... any code reading this data will be horrible.
- Use
entrySet() instead of keySet(), then you don't need to fetch the value by key