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

Anthony Forloney
  • 90,123
  • 14
  • 117
  • 115
ngreenwood6
  • 8,108
  • 11
  • 33
  • 52

1 Answers1

4

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.

Community
  • 1
  • 1
Anthony Forloney
  • 90,123
  • 14
  • 117
  • 115