top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Which one you will prefer in Java between Array and Array Listes for storing object and why?

+1 vote
383 views
Which one you will prefer in Java between Array and Array Listes for storing object and why?
posted Oct 22, 2017 by Madu Hansi

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Lets first understand what ate these two

Array: Simple fixed sized arrays that we create in Java, like below

  int arr[] = new int[10]   

ArrayList : Dynamic sized arrays in Java that implement List interface.

 ArrayList<Type> arrL = new ArrayList<Type>();

      Here Type is the type of elements in ArrayList to be created

Now coming to your problem should be we use Array and ArrayList, It depends on the context if we know the max-size before hand we should use Array and if we don't then we should use ArrayList.

answer Oct 23, 2017 by Salil Agrawal
It's Ok. Thanks a lot
...