Hi all
is there a method which returns the name of the instance of an object ? i
mean if we have the following:

Student ali=new Student();
printStudentname(ali);

public static void printStudentname(Student x){
System.out.println(/* x.______ or ______(x) so the out put is "ali" which is
the name of the object instance*/);
}
or i would have to add a name field to the class Student and write a
getName() method to accomplish this.
i tried x.getClass().getName() but it returns the name of the class of this
object instance "x" which is Student.
if anyone knows such a method it will be very useful to tell me about.

thank you.
-- 
Abbas Zaini

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to