Q:

creating an array in a class

I have a compilation problem in a Java program:
class FigureEditor {
   int[] a;             ----- Syntax error on token ";", , expected
   a = new int[5];
}

What am I doing wrong?

A:

You can't have "floating" statements in the class body.
Either initialize it directly:
int[] a = new int[5];

Or use an initializer block:
int[] a;
{
a = new int[5];
}

A:

class FigureEditor
{
  int[] a = new int[5];
}

You can't use variables outside a method.

