... in accordance with the intended use that you stated, it seems that
your trouble isn't about some feature's lacking ... its more about
some kind of misleading in your design... I don't think it will be a
feature since it doesn't seems to keep with the way of thinking in
OOP...

On 25 ago, 00:29, Abbas Zaini <[email protected]> wrote:
> so there is no way to get the name of the reference of an object's instance,
> but as long as the parameter is passed to the method by reference, it  means
> that the compiler recognizes it, and it is possible to get the string which
> references the instance, maybe such a method gets available in future
> versions of JDK, because it is really useful to have it, it saves you the
> effort of creating a new name field and initiate it in each object
> instance,and in the project which i am working on it saves me a whole line
> after each object instance.
>
> On Tue, Aug 25, 2009 at 5:41 AM, Christy John <[email protected]>wrote:
>
>
>
>
>
> > Abbas Zaini wrote:
>
> >> 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
>
> >>  yeah, you need to used the getName() method. If you use ali.getName() it
> > returns Student, the name of the class.
> > Thanks
> > Christy John
>
> --
> Abbas Zaini- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -

--~--~---------~--~----~------------~-------~--~----~
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