<Java> When creating a fixed-length (row) * variable-length (column) two-dimensional array

At the beginning

For the time being, make a note of what I noticed the other day. I couldn't find it even after searching ...

It is not clear how long a variable length column will be.

Implementation

Sample.java


//Definition--50 lines are fixed
ArrayList[] list = new ArrayList[50]

for(int i = 0;i < 50;i++){
  list[i] = new ArrayList(); //Make a variable length column here
}

Sample.java


//Add an item to a row (add a column)
list[3].add("apple"); //This is one row plus

//Gets the value of any column from the specified row.
list[3].get(4) //Get the data in the 3rd row and 4th column

Recommended Posts

<Java> When creating a fixed-length (row) * variable-length (column) two-dimensional array
When seeking multiple in a Java array
[Java] Precautions when converting variable-length argument parameters into an array
[Ruby] Extracting a two-dimensional array
Java learning memo (creating an array)
How to make a Java array
[Java] How to turn a two-dimensional array with an extended for statement
[Creating] A memorandum about coding in Java
Creating a matrix class in Java Part 1