Hi Friends , if i mention : int arr[] = new int{1,2 3,4}; =>it's illegeal int arr[] = new int[]{1,2,3,4};=>it's legal can anybody explain me y is it so ? rahul
lee dalais
Ranch Hand
Joined: Feb 28, 2001
Posts: 67
posted
0
after the 'new' keyword is used in an array declaration, [] is expected to define the dimension(size), so: int arr[] = new int{1,2 3,4}; is illegal but below is a legal array construction statement: int arr[] = new int[]{1,2,3,4}; look here in the JLS