This code compiles without error:
Code:
public class hello {
 public static void main(String[] args){
   int[] vector = new int[10];
   vector[0]=3;
 }
}
Whereas this code does not compile and generates several errors:
Code:
public class hello {
 int[] vector = new int[10];
 vector[0]=3;
 public static void main(String[] args){
 }
}
The errors i get are just like this one:
Code:
>./hello.java:3: error: ']' expected
>vector[0]=3;
>       ^
So i feel tempted to conclude that an expression of the form array[i] outside of any method context is illegal?