Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Programmer Certification (OCPJP)
Arrays
Ritu Kapoor
Ranch Hand
Posts: 102
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Code:
---------------------------------------------
class arrays{
public static void main(
String
[] args) {
int []a3,[]a4; // 1
int []a5,a6[]; // 2
}
}
----------------------------------------------
Why the statement at //1 is giving compilation error while the statement //2 has compiled.
Seb Mathe
Ranch Hand
Posts: 225
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Both lines begin with int [] : You're trying try to declare variables of type int[].
[]a4 is not a valid variable name.
Line 2, a6 is ok because it's an int array of array...
The code could be "rewrited" like that, maybe it wille be more clear :
int a3[], []a4[];
int a5[], a6[][];
Regards,<br />Seb<br /> <br />SCJP 1.4
tian haitao
Greenhorn
Posts: 4
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
That's right.
Although
int []a5,a6[]; //2
passed complie,the result is not you want.
a6[] has change to a6[][].
The standard method is :
int[] a1,a2;
[ September 29, 2005: Message edited by: tian haitao ]
trying and trying.
You guys haven't done this much, have ya? I suggest you study this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
3&4D array
Initializing a 2D array
Multi Dimensional Arrays
Multidimensional arrays
need help with array
More...