Skip to content
Advertisement

Java: Arraylist of Array

I want to make an arraylist of an array of 2 elements. So, I have unknown rows and known columns (i.e. 2). E.g. [{name1, ID1}, {name2, ID2}, …]

I also have to return this arraylist.

I tried using

JavaScript

but don’t know how to proceed.

Please advise.

Advertisement

Answer

When you define a ArrayList must use a class. In this case, you can use a class Person:

JavaScript

Then, we can define a ArrayList of Persons:

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement