likeIT
likeIT

Reputation: 307

defining static arrays in Java

hello I have some question about writing class in Java, why this one is not working:

public class EvenFibonacciSequences {

    static final int num = 45;

    static int calculated[num];
...
}

how can I write it correctly? thanks in advance

Upvotes: 0

Views: 203

Answers (2)

Lak Ranasinghe
Lak Ranasinghe

Reputation: 240

You can't declare an array with an array size.It is illegal. Instead, you should do it (specifying the array size) during array initialization as @likeIT has given.

Upvotes: 0

John Chadwick
John Chadwick

Reputation: 3213

You probably want

static int[] calculated = new int[num];

At least, I think that's right (have not dealt with Java in a while.)

Upvotes: 5

Related Questions