Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reg array initialization

 
Pradeep Kumar
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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};

Regards,
Pradeep
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"PradeepKumar", please check your private messages for an important message from me.
[ October 06, 2007: Message edited by: Bear Bibeault ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic