N
N
nano_e_t_42016-11-12 13:10:44
Java
nano_e_t_4, 2016-11-12 13:10:44

What's wrong with nested arrays?

Hello everyone
Tell me, what could be wrong with such a design?

ArrayList<ArrayList<Integer>> list = new ArrayList<ArrayList<Integer>>(10);

I read on the forums, they say it's bad ...
Thank you

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
al_gon, 2016-11-12
@al_gon

Where are the arrays?
If you mean ArrayList then it's not an array. If the ones inside the ArrayList is another matter.
In addition to a "tight" binding to a specific implementation of List through ArrayList, I don’t see anything bad.
But in principle, depending on the case, binding to a specific implementation can be beneficial and necessary.
As for me, this option is better.

final List<List<Integer>> list = new ArrayList<>(10);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question