-2
  List<int[][]> matrices = new ArrayList<>();

my arraylist is this. I wanna print all the elements in 2-d arrays which store into the arrayList. How can I do this ?

I tried some solutions here but these are not working for me.

2

1 Answer 1

1

Iterate the list, and use Arrays.deepToString to print each element:

matrices.stream()
    .map(Arrays::deepToString)
    .forEach(System.out::println);

Or, for versions of Java which don't support streams:

for (int[][] matrix : matrices) {
  System.out.println(Arrays.deepToString(matrix));
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.