How can you assign nondefault values to array elements when the array is declared? Give an example.

What will be an ideal response?


You can assign nondefault values to array elements at declaration by including a comma-separated list of values enclosed within curly braces. For example, if you want to create an array named myScores and store five test scores within the array, you can use any of the following declarations:
int[] myScores = new int[5] {100, 76, 88, 100, 90};
int[] myScores = new int[] {100, 76, 88, 100, 90};
int[] myScores = {100, 76, 88, 100, 90};

Computer Science & Information Technology

You might also like to view...

Indexes are numbered starting at _________

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

____________________ is a feature that stores DNS queries on the local site for fast hostname-to-IP address resolution.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

In a one-to-one relationship, either table could be the Primary table

Indicate whether the statement is true or false

Computer Science & Information Technology

What are two of the goals of audio package design?

What will be an ideal response?

Computer Science & Information Technology