Tuesday, 20 August 2013

Array declaration showing error outside main

Array declaration showing error outside main

The same type of declaration for an array is showing error when its
outside the main() but complies without error when in main()
public class Array {
int arr1[];
arr1 = new int[10]; // shows <identifier> expected error
public static void main(String args[]){
int arr2[];
arr2 = new int[10];
}
}

No comments:

Post a Comment