THERE IS NO PROBLEM WITH THIS AT ALL. VARIABLE NAMES AND CLASS NAMES ARE IN ALTOGETHER DIFFERENT NAMESPACES AND DON'T INTERFERE WITH EACH OTHER AT ALL, IN ANY CONTEXT. YOU CAN ALSO HAVE A METHOD WHOSE NAME IS THE SAME AS THE CLASS IT APPEARS IN, SO, FOR EXAMPLE, THE FOLLOWING CODE WOULD BE PERFECTLY LEGAL JAVA:
TEST TEST = new TEST().TEST();
P.S. ARE YOU FROM NIGERIA?
P.P.S. I'M MOVING THIS TO JAVA IN GENERAL (BEGINNER).
Make visible what, without you, might perhaps never have been seen. - Robert Bresson
Tony Morris
Ranch Hand
Joined: Sep 24, 2003
Posts: 1608
posted
0
It's important to note that objects don't have names. It is this very fact that makes it extremely difficult to talk about objects, and results in great confusion. What you have there is an "object reference", which do have names; the object referred to by the reference does not.
As literal and precise as the distinction may be, I don't find it very helpful to insist on saying 'the object (in memory) referred to by "o"' any more than it's helpful to say 'the object (on the floor) referred to by "chair"'.
Tony Morris
Ranch Hand
Joined: Sep 24, 2003
Posts: 1608
posted
0
Originally posted by Michael Ernest: As literal and precise as the distinction may be, I don't find it very helpful to insist on saying 'the object (in memory) referred to by "o"' any more than it's helpful to say 'the object (on the floor) referred to by "chair"'.
I teach at a university; I see this often: "my object cannot be null, why do I get NullPointerException?" "Object x; when is x eligible for garbage collection?" "Java passes primitive types by value, and objects by reference" "...but I created the array with 'new', yet the elements are still null" <insert-a-zillion-other-remarks-here/>
Can you see the problem by not providing the distinction?
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
posted
0
Originally posted by Michael Ernest: As literal and precise as the distinction may be, I don't find it very helpful to insist on saying 'the object (in memory) referred to by "o"' any more than it's helpful to say 'the object (on the floor) referred to by "chair"'.
In a discussion between experienced developers, I'd probably agree.
In a beginner's forum, I'd assume that it helps to be more pedantic, because differentiating between an object and reference variables is a common problem for beginners.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.