Arrays


int[] number;
int number

String[] words;
String words;


Try to differentiate the codes above.

The codes on the left side are different from the right. The codes on the left are arrays. What is an array?

An array is similar to any other variables, only that it has its own subarrays and elements. Subarrays are arrays within an array, while elements are found inside the array.


example:

int[] variable = {element, element, element, . . . . .}
or
String[] variable = {{element},{element},{element}}


In declaring an array, the syntax is int[] variable = new Int[size of your array]

No comments:

Post a Comment

Extended Search

Custom Search
Hello World