jQuery in Action, 3rd edition
The moose likes Java in General and the fly likes Reg array initialization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Reg array initialization" Watch "Reg array initialization" New topic

Reg array initialization

Pradeep Kumar
Ranch Hand

Joined: Sep 11, 2007
Posts: 77
What is the differnece between the below two declarations.
As results of both the statements are the same.Apart from that are there any other differences.

int[] aray1 = {1,2,3,4,5,5};
int[] aray2 =new int[]{1,2,3,4};


SCJP 1.6
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Nope, no difference we need to think about.

Some of us wish we could use the first syntax anyplace an array is needed instead of only in initializations.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63532

"PradeepKumar", please check your private messages for an important message from me.
[ October 06, 2007: Message edited by: Bear Bibeault ]

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link: http://aspose.com/file-tools
subject: Reg array initialization
It's not a secret anymore!