Two Laptop Bag*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Array Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Array Problem " Watch "Array Problem " New topic
Author

Array Problem

Rahul Pawar
Ranch Hand

Joined: Mar 13, 2001
Posts: 38
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
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Array Problem