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




Reply With Quote