ngreenwood6
ngreenwood6

Reputation: 8216

Java / Android self naming

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

Upvotes: 1

Views: 297

Answers (1)

Anthony Forloney
Anthony Forloney

Reputation: 91816

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.

Upvotes: 4

Related Questions