Computer Science, asked by naziasyed3614, 1 year ago

how to initialize a dynamic array in java?

Answers

Answered by amannishad0512p5zxh6
0

n=10;

int a [ ]=new int [n];

Now you got

Answered by Oreki
2

Java has built-in dynamic arrays like Vector, ArrayList, LinkedList and CopyOnWriteArrayList.

For most cases ArrayList satisfies our needs, so,

We can initialize a ArrayList by,

   ArrayList<Type> object_name = new ArrayList<Type>( ); or,

   ArrayList<Type> object_name = new ArrayList<Type>(

       Arrays.asList(Object obj1, Object obj2, Object obj3, ....));

Similar questions