Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Assignment of an Array to a key

 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Please look at the following code:
String[] favoriteMusic = { "Zero7","BT","Frou Frou"};
request.setAttribute("musicList","favoriteMusic");



Is it correct to assign a string array to a key called "musicList".


With regards,
Padma priya N.G.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've got extra double quotations. It should be :


Yes it's ok, because as you know, arrays behave like any objects.
 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks.
Padma priya N.G.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic