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
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');
The replication of the name (symbol) a is what is inconvenient and a bit noisy. In a language with macros, one could define this so that the copying would be automatic in the source code program.
make(A, a);
or makeA(a)
While you can easily get the name of a variable's class by invoking .getClass().getCanonicalName() or .getClass().getSimpleName() (depending on whether you want the fully qualified name), it is not so easy to get the name of a variable. Java bytecode does not need to preserve the names of local variables (which are represented using push/pop operations on the stack); however, Java bytecode may contain the original names in comments. So, you might try reading the .class files from the .jar files and attempt to extract the variable names from the .class files, assuming that the compiler has included them as comments. As for member variables (i.e. fields), you can use reflection to get a class's field names.
I had the same problem, look that solution...
DocumentoMB mb = new DocumentoMB();
System.out.println(mb.getClass().getSimpleName());
You can always create name variable in the object's class, and use that variable beside others to pass information about this object.
You can't.
If you compile with debug symbols then the .class file will contain a table of variable names (which is how debuggers map variables back to your source code), but there's no guarantee this will be there and it's not exposed in the runtime.