Use string in place of variable name

后端 未结 3 769
陌清茗
陌清茗 2020-12-20 22:30

If you have a Java variable named xyz. Then later on I define a string which has the value of the named variable I want to play with.

String x=\"xyz\";
         


        
3条回答
  •  太阳男子
    2020-12-20 22:41

    The short answer is that you can't do something like this. That just isn't the way the Java language works. The long answer is that you might be able to simulate something using the Reflection API.

提交回复
热议问题