what arrays are dynamic arrays code example

Example 1: declaring 2d dynamic array c++

int** arr = new int*[10]; // Number of Students
int i=0, j;
for (i; i<10; i++) 
	arr[i] = new int[5]; // Number of Courses
/*In line[1], you're creating an array which can store the addresses
  of 10 arrays. In line[4], you're allocating memories for the 
  array addresses you've stored in the array 'arr'. So it comes out 
  to be a 10 x 5 array. */

Example 2: how to create dynamic string array in java

ArrayList<String> mylist = new ArrayList<String>();
mylist.add(mystring); //this adds an element to the list.

Tags:

Java Example