+ 1
How should i do to set something in arrays?
3 Respostas
+ 4
int array[5];
array[0] = 42;
array[1] = 0;
// etc
or using a loop
for (int i = 0; i < 5; i++)
array[i] = some_value;
+ 1
tq
+ 1
You can also assign values in the declaration, but the syntax depends on the programming language:
Java:
int[] nums = {1,2,3};
OR
int[] nums = new int[]{1,2,3};
Javascript:
var nums = [1, 2, 3];
C#:
int[] nums = { 1, 3, 5, 7, 9 };
.
.
.