#### Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

# Array Full of Numbers

Why is it that Processing does not like the arrays to be put like this?

``````int[] NE = new int[4];
NE[0] = 60000;
NE[1] = 55000;
NE[2] = 45000;
NE[3] = 46000;

int[] ND = new int[4];
ND[0] = 80000;
ND[1] = 70000;
ND[2] = 40000;
ND[3] = 45000;

int[] F = new int[4];
F[0] = 60000;
F[1] = 35000;
F[2] = 24000;
F[3] = 28000;

int[] M = new int[4];
M[0] = 120000;
M[1] = 100000;
M[2] = 110000;
M[3] = 100000;
``````
Tagged:

• edited April 2015 Answer ✓

Your posted code works perfectly. And it's running in Processing's "static mode" now.
See the section "Hello Mouse" at the link below to know about static & interactive modes:
https://processing.org/tutorials/overview/

Now if you change it for the regular "interactive mode" it's not gonna work the way it is now.
Not b/c of Processing, but Java's!

In the section where we declare the class' fields, outside of any of its methods, regular statements aren't allowed! For example: `NE[0] = 60000;`
However, if you really wish to run non-declaration statements there, we can place them inside a curly brace block:

``````final int[] NE = new int[4];
{
NE[0] = 60000;
NE[1] = 55000;
NE[2] = 45000;
NE[3] = 46000;
}
``````

But I particularly would go w/ this simpler form:

`static final int[] NE = {60000, 55000, 45000, 46000};`

Everything GotoLoop has said is correct but the following code shows 2 alternative ways of doing what you want

Verbose Code

``````int[] NE = new int[4];
int[] ND = new int[4];
int[] F = new int[4];
int[] M = new int[4];

void setup() {
NE[0] = 60000;
NE[1] = 55000;
NE[2] = 45000;
NE[3] = 46000;

ND[0] = 80000;
ND[1] = 70000;
ND[2] = 40000;
ND[3] = 45000;

F[0] = 60000;
F[1] = 35000;
F[2] = 24000;
F[3] = 28000;

M[0] = 120000;
M[1] = 100000;
M[2] = 110000;
M[3] = 100000;
}
``````

Less verbose code

``````int[] NE, ND, F, M;

void setup() {
NE = new int[] { 60000, 55000, 45000, 46000 };
ND = new int[] { 80000, 70000, 40000, 45000 };
F  = new int[] { 60000, 35000, 24000, 28000 };
M  = new int[] { 12000, 10000, 11000, 10000 };
}
``````