79404309

Date: 2025-02-01 02:03:18
Score: 1.5
Natty:
Report link

What I don't understand from you question is whether or not your myArrayN objects are hanging "loose" in the memory and you have to collect them in your loop or if they are already organized in some way into one object.

For now, I assume you have the myArrayN in some form of myArrayOfArrays = ArrayList<>();, so items can be accessed by index. Are the arrays in your example real arrays? Say String[] myArray = new String[](n); or are they given in form of Java Collections like List<String> myArray = new ArrayList<>();?

HashMap<Integer,ArrayList<String>> map = new HashMap<>();

int numberOfArrays = myArrayOfArrays.size();

for (int i = 1; i <= numberOfArrays; i++) {
  // if myArrayN is String[] use:
  map.put(i, new ArrayList<>(Arrays.asList(myArrayOfArrays.get(i))));
  // if myArrayN is ArrayList<String> use
  map.put(i, myArrayOfArrays.get(i));
}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Starts with a question (0.5): What I
Posted by: WolfiG