Can an ArrayList be a two-dimensional array?

I am new to Java, programming and StackOverflow. I need to use a list where I can add or remove things and not know the initial size (e.g. ArrayList), but I also need it to be two-dimensional. I read on Google and StackOverflow, and I cannot find a specific answer. Is it possible? And if not, can you point me in the right direction? Thanks in advance.

+4
source share
2 answers
ArrayList<ArrayList> arrList2D = new ArrayList<ArrayList>(2); arrList2D.add(new ArrayList()); arrList2D.add(new ArrayList()); 

arrList2D is a 2D ArrayList.

+5
source

Well, you can always try writing simple code and see if this work. By the way, you can use the list of arrays in the list of arrays, and I'm sure it will be a very bad idea.

+3
source

Source: https://habr.com/ru/post/1397958/


All Articles