Thursday, 19 July 2012

JAGGED ARRAYS



Jagged arrays are often called array of arrays. An element of a jagged array itself is an array. For example, you can define an array of names of students of a class where a name itself can be an array of three strings - first name, middle name and last name. Another example of jagged arrays is an array of integers containing another array of integers. For example,

int[][] numArray = new int[][] { new int[] {1,3,5}, new int[] {2,4,6,8,10} };

Again, you can specify the size when you call the new operator.

No comments:

Post a Comment