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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Paul Clapham
• Bear Bibeault
• Liutauras Vilda
• Devaka Cooray
Sheriffs:
• Knute Snortum
• Junilu Lacar
• Henry Wong
Saloon Keepers:
• Ron McLeod
• Stephan van Hulst
• Tim Moores
• Carey Brown
• Tim Holloway
Bartenders:
• salvin francis
• Frits Walraven
• Piet Souris

Arrays - JLS

Ranch Hand
Posts: 145
Hi All,

Here are some examples of declarations of array variables that create array objects:

Exception ae[] = new Exception[3];
Object aao[][] = new Exception[2][3];
int[] factorial = { 1, 1, 2, 6, 24, 120, 720, 5040 };
char ac[] = { 'n', 'o', 't', ' ', 'a', ' ',
'S', 't', 'r', 'i', 'n', 'g' };
String[] aas = { "array", "of", "String", };

How do these --

int[] factorial = { 1, 1, 2, 6, 24, 120, 720, 5040 };
char ac[] = { 'n', 'o', 't', ' ', 'a', ' ', 'S', 't', 'r', 'i', 'n', 'g' };

create array objects ?

author and iconoclast
Posts: 24203
43
Well, you've seen the syntax

int[] x;
...
x = new int[] { 1, 2, 3 };

right? The syntax

int[] x = { 1, 2, 3};

is just a shortcut for that, allowed only when the variable is being declared.

Arnb Sen
Ranch Hand
Posts: 145
yes.. of course.. what was I thinking

 It means our mission is in jeapordy! Quick, read this tiny ad! Java file APIs (DOC, XLS, PDF, and many more) https://products.aspose.com/total/java