views:

60

answers:

1

I am about to start developing an Android application and had a question if in Java there self naming. For instance say I had a variable named dog that held the value of scruffy.

Could I then create a variable named scruffy from that variable. In PHP it would be $$dog. That would make a variable with the name scruffy.

If this is possible please provide example

+2  A: 

In PHP, $$dog, or self naming as you refer to it as, has a special name. It is known as variable variables. Android is written in Java, which does not have variable variables support.

See this related question, Does Java support variable variables? for a possible work-around.

Anthony Forloney
Thanks. That's perfect will accept ur answer when it let's me
ngreenwood6
No problem, glad to help.
Anthony Forloney