1.

How Do You Declare Arrays?

Answer»

To declare arrays there are two options. They are as follows:

  1. Array of primitive
  2. Array of reference.

Array of primitive: int[] test= new int[3]
Array of reference: threads[] thread=new threads[5]

we had mentioned the SIZE of array on either declarations because JVM cannot ALLOCATE memory for objects of arrays until we give the size of an array.

To declare arrays there are two options. They are as follows:

Array of primitive: int[] test= new int[3]
Array of reference: threads[] thread=new threads[5]

we had mentioned the size of array on either declarations because JVM cannot allocate memory for objects of arrays until we give the size of an array.



Discussion

No Comment Found