This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Dans Array Questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Dans Array Questions" Watch "Dans Array Questions" New topic
Author

Dans Array Questions

Madhu Kumar Vatts
Ranch Hand

Joined: Apr 01, 2004
Posts: 74
Array Question from http://www.danchisholm.net,

int []a1; //compiles well,
int []a1,[]a2; //doesnot compile

Can anybody explain why? The reason given was " the brackets appearing before the identifier for array variable a2 are not associated with the type or the identifier. "..My question is if this is the case than why does
int []a1 compile, Is it equal to int[] a1;


Thanks for replying
Madhu


Oracle Certified Enterprise Architect (Part 1);SUN Certified Programmer;SUN Certified Business Component Developer;SUN Certified Web Component Developer;
Oracle Certified WebServices Developer;Oracle Certified Java Persistence API Developer;Oracle Certified SQL Expert;IBM Certified XML Solution Developer
rengarajan vaikuntam
Ranch Hand

Joined: Oct 04, 2004
Posts: 37
Madhu
Its something like this
int i,int j;
Hope u got it.
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
int []a1,[]a2; // is illegal

int []a1,a2; // is legal, it's the same as:
int a1[],a2[]; // and also the same as:
int a1[]; int a2[];


int []a1,a2[]; // is legal, it's the same as:
int a1[]; int a2[][];
[ October 28, 2004: Message edited by: Mike Gershman ]

Mike Gershman
SCJP 1.4, SCWCD in process
Madhu Kumar Vatts
Ranch Hand

Joined: Apr 01, 2004
Posts: 74
Thanks Mike
 
jQuery in Action, 2nd edition
 
subject: Dans Array Questions
 
Similar Threads
Dan's Mock test on Mutil-dimensional arrays
A question from - danchisholm.net
Array assign
Mock Exam Array question
Nested Class - Mock Question & Explanation on Dan Chisholm's website.