• Post Reply Bookmark Topic Watch Topic
  • New Topic

EL expression..[ ] operator  RSS feed

 
adithya kallu
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When going through HF jsp& sevlets with an example of el, if a class Person has Array of Dog(dogs)elements and Dog has a name property, how would i access that using the [] operator , i know i can do it with . operator

person.dogs[0].name // to access the first element of dogs array

Thank you
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
adithya kallu
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually i was wondering is it possible to elimate the . operator completely
 
Stefan Evans
Bartender
Posts: 1834
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In general anything written as a.b can be written as a["b"]

So following the same rule the Bear applied:


You can use single/double quotes as you like. Just be consistent.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!