| Author |
How to print the name of an object in java ?
|
PrachiS Shah
Greenhorn
Joined: Sep 02, 2010
Posts: 10
|
|
how to print the name of an object in java ?
for eg.
String start = "hello";
Now how to print the name of the object ?
|
 |
sharad koshal
Greenhorn
Joined: Sep 06, 2010
Posts: 4
|
|
good question.even i am getting confused
.experts please come in.
please help us out.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19232
|
|
You can't; the variable name isn't stored with the object. Furthermore, any object can have multiple references ("names"):
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 10043
|
|
Further, the variable name is really only useful to someone looking at the source code. It's a way for us HUMANS to identify thing in the code.
When the program is compiled and being run, the JVM or OS can really use whatever name it wants.
|
Never ascribe to malice that which can be adequately explained by stupidity.
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12953
|
|
|
Objects do not have names - variables have names. But a variable is not the same as the object that it refers to. As Rob shows, you can have multiple variables that refer to the same object.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
 |
|
|
subject: How to print the name of an object in java ?
|
|
|