0 votes
in JAVA by

Which of the following is the correct syntax for declaring an array of integers in Java?

a) int[] myArray = {1, 2, 3, 4, 5};

b) int myArray[] = {1, 2, 3, 4, 5};

c) int[] myArray = new int[5];

d) int myArray[5] = {1, 2, 3, 4, 5};

1 Answer

0 votes
by

Answer: a) int[] myArray = {1, 2, 3, 4, 5};

Explanation: The syntax for declaring an array of integers in Java is to use the int[] keyword followed by the name of the array, an equal sign, and a list of values enclosed in curly braces.

Related questions

0 votes
asked May 7 in JAVA by SakshiSharma
0 votes
asked May 4 in JAVA by rahuljain1
...