Anonymous array
They are used to construct and initializing the array and then assigning the array to previously declare array reference variable.
Following is the example of creating anonymous array
int[] testScores;
testScores = new int[] {4,7,2};
The preceding code creates a new int array with three elements, initializes the
three elements with the values 4, 7, and 2, and then assigns the new array to
the previously declared int array reference variable testScores. We call this
anonymous array creation because with this syntax you don't even need to assign
the new array to anything
They are used to construct and initializing the array and then assigning the array to previously declare array reference variable.
Following is the example of creating anonymous array
int[] testScores;
testScores = new int[] {4,7,2};
The preceding code creates a new int array with three elements, initializes the
three elements with the values 4, 7, and 2, and then assigns the new array to
the previously declared int array reference variable testScores. We call this
anonymous array creation because with this syntax you don't even need to assign
the new array to anything
No comments:
Post a Comment