0

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

1
  • If you are trying to calculate the even Fibonacci values, you don't need to define an array. You just need one loop which can calculate one even value per iteration. Commented May 5, 2011 at 10:18

2 Answers 2

5

You probably want

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

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

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.