0 votes
in JAVA by
How to declare array in java?

1 Answer

0 votes
by
How to declare array in java?

"To declare an array, define the variable type with square brackets:

String[] cars;

We have now declared a variable that holds an array of strings. To insert values to it, we can use an array literal - place the values in a comma-separated list, inside curly braces:

String[] cars = {""Volvo"", ""BMW"", ""Ford"", ""Mazda""};

To create an array of integers, you could write:

int[] myNum = {10, 20, 30, 40};"

Related questions

0 votes
asked Oct 18, 2020 in JAVA by sharadyadav1986
0 votes
asked Oct 21, 2020 in JAVA by rahuljain1
...