i am experementing on ArrayList which contains different data types and an int array and I want to access a value from the array for example number 55. Can I directly access this array without using for-loops? How to override the toString method of this int array, so that I dont get entries like this: [I@2401f4c3? Also I dont know how to define for loop correcly because it prints the array just 1 time in console but it should print 4 times. Have any ideas please share with us.
ArrayTest class:
public class ArrayTest {
public static void main(String[] args) {
ArrayList<Object> strangeList = new ArrayList<>();
strangeList.add("String");
strangeList.add(3823);
strangeList.add(new int[] { 329, 23882, 55, 932 });
System.out.println(strangeList.size());
System.out.println();
for (int i = 0; i < strangeList.size(); i++) {
if (i == 2) {
for (int j = 0; j < strangeList.size(); j++) {
System.out.println(strangeList.get(j));
}
}
}
}
}