+2 votes
579 views
in Programming by (1.6k points)

I am using this for adding multiple Arrays in an Array List, but not working can you tell me how can i do this?

Thanks for your answer!

    

static int elements = 13; 
public static void main(String[] args)
    {
        int[] person = new int[4];
        ArrayList personID = new ArrayList();

        experiment(personID, person);
    }
private static void experiment(ArrayList personID, int[] person)
    {
        for(int i = 0; i < elements; i++)
            {
                person[0] = i;
                person[1] = i;
                person[2] = i;
                person[3] = i;

                personID.add(person);
            }
        System.out.print(personID);
    }



1 Answer

0 votes
by (1.2k points)

I think you should use this when you are printing personID

for (int[] a : personID)

System.out.println(Arrays.toString(a));

Not a Member yet?

Ask to Folks Login

My Account

Your feedback is highly appreciated