1

How do you assign values to ArrayList<int[]>, like you do with 2D array anArray[0][0] = val ?

6 Answers 6

2
int[] row = list.get(rowNumber);
row[columnNumber] = value;
0
1
Vector<int[]> vector=new Vector<int[]>();
vector.get(0)[0]=1;
1

You can insert a specified element at a specified position using the add method.

1

you can use set as described here

Vector<int[]> v = new Vector<int[]>[10];
v.set(0, new int[10]);

and then get a value

int[] curr = c.get(0);
1

list.add(int index, String Element);

0

you can add elements to arraylist using add metheod.

    int[] x={1,2,3,4,5};
 ArrayList<int[]> demo = new  ArrayList<int[]>();
    demo.add(x);

you can, inserts the specified element at the specified position in this list.

  add(int index, E element)

index : index at which the specified element is to be inserted. element element to be inserted here must be integer array

   demo.add(5, x);

element inserted in 5th position in arraylist

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.