Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EL expressions . vs [ ]  RSS feed

 
abhilash reddy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello all,
iam a newbie to EL plz help me ,if we have a code some thing like this
class Person{
Dog dog;
setter and getter methods for dog object
}

class Dog{
Toy toy;
setter and getter methods for toy object
}
and finally Toy class with a name property

i know we can toy name using
person.dog.toy.name //ofcourse person is available
but if we had to do with only [] operator how we do it //no dots at all
 
Stefan Evans
Bartender
Posts: 1836
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in general expra.exprb is equivalent to expra["exprb"]

person.dog.toy.name
should be equivalent to
person["dog"]["toy"]["name"]
 
abhilash reddy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you very much, i appreciate ur reply
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66208
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"cool boy",

There aren't may rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!