0

I'm working with Processing and I have an Arraylist of arrays

ArrayList< ICurve []> c = new ArrayList< ICurve []> ();

I need to select a specific item in a specific array of my arraylist, but I can't understand how to do it. I know how to iterate inside the arraylist with the for cycle, but I can't understand how to select the item with a specific index.

Thanks in advance for your help!

2 Answers 2

1

An Arraylist of arrays returns an array, so just use bracket notation:

ArrayList <Integer[]> a = new ArrayList <Integer[]> ();    
void setup(){
    a.add(new Integer[] {1,2,3});
    println(a.get(0)[1]);// prints 2
    }
Sign up to request clarification or add additional context in comments.

Comments

0
ArrayList< int[] > myArrayList = new ArrayList< int[]> ();
void setup()
{

  int[] myArray = {0, 1, 2, 3};
  myArrayList.add(myArray);
  println(myArrayList.get(0)[0]);

}

I've used a primitive datatype in this example, but the same principle applies.

Comments

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.