• 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

El question in HFSJ - Page 380

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have questions about EL . should the [] contain "" or not ?
Page 375 says tat if there are no quotes inside brackets , container evaluates by searching for an attribute.
But for drop magnet question in Page 380 , toys[1].name is given as the correct answer. I was expecting toys["1"].name since without "" , container would start searchnig for an attribute.
And book also warns that rules of java generally dont apply to EL .So I thought , plain Java array addressing of toys[1].name cannot be inside a ${} expression.

Can someone clarify this ? Thanks
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ram,

You can use either way, both toys[1].name or toys["1"].name works. Index can be used with quotes or without quotes for List and Array objects. Here getToys returns array of Toy objetcs. You can see the details on page 372.

Hope this helps.

Alankar Yannam
 
I've read about this kind of thing at the checkout counter. That's where I met this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic