I wrote this question because I can't seem to find any answer that suits my needs.
What I'm trying to achieve: I want to create new array e.g. array3
in java that would hold two or more arrays from different arrays, e.g. array3 = [[array1], [array2], [arrayN]].
In Python I know how to append 2 lists to 3rd list, like:
list1 = [1, 2, 3]
list2 = [11, 22, 33]
list3 = []
for i in range(len(list1)):
list3.append([list1[i], list2[i]])
print(list3)
and result will be: [[1, 11], [2, 22], [3, 33]]
And I can't find the right answer how to do this in Java. Is there any way to achieve this goal in Java?
Added what I have done yeat:
String[] list1 = integer1.split(";");
String[] list2 = integer2.split(";");
String[] list3 = integer3.split(";");
String[] list4 = integer4.split(";");
int lenOfList1 = list1.length;
int lenOfList2 = list2.length;
int lenOfList3 = list3.length;
int lenOfList4 = list4.length;
int result1 = Integer.compare(lenOfList1, lenOfList2);
int result2 = Integer.compare(lenOfList3, lenOfList4);
int result3 = Integer.compare(result1, result2);
ArrayList<String> ar = new ArrayList<String>();
if (result3 == 0) {
System.out.println("This is result: " + result3 + ", and we are good to go now!");
for(int i=0; i < lenOfList1; i++){
ar.add(list1[i]);
ar.add(list2[i]);
ar.add(list3[i]);
ar.add(list4[i]);
}
} else {
System.out.println("This is result: " + result3 + ", and this is the end!");
}