How can I get an Object's name in java?

后端 未结 9 1767
陌清茗
陌清茗 2020-12-10 05:30

like this, A a = new A(), how can I get a\'s name?(Get a String \"a\" from a) ?


There is a JPanel contains some JTextFields, a map contains all the JTextFields

9条回答
  •  醉梦人生
    2020-12-10 06:02

    You can't and it seems like you're doing something wrong if you need to do this. However, if you really want to pursue the logic you've outlined, why don't you do the following:

    Add a String member to A and in a constructor, assign it. Something like this:

     A a = new A('a');
    

提交回复
热议问题