Ok, so in C a pointer just points to a memory location, if whatever is
at that locations moves you get into trouble. But with Java, a
reference points to an object which has its own memory address that
may change and the reference wont be affected?

Also, Weiqi Gao says that Java has no pointers (unless I miss
understood you), but Casper says "Yes, Java has pointers", which is
it???

On Nov 12, 10:49 am, Casper Bang <[EMAIL PROTECTED]> wrote:
> That didn't come out right. lol Java always passes a copy of the
> pointer/reference, but does so by value. So if you cross a stack frame
> boundary (say call into a method) there will now be two distinct
> references to the thing. That's why a swap won't work, you may swap
> your second reference but that has no effect on the first once you get
> back from the call and pop the old stack frame. Hmm tricky to explain.
>
> /Casper
>
> On Nov 12, 12:37 am, Casper Bang <[EMAIL PROTECTED]> wrote:
>
> > Yes, Java has pointers. But it has no support for pointer arithmetics
> > and you cannot implement a swap method. Java always passes a copy
> > (reference) to a pointer.
>
> > /Casper
>
> > On Nov 12, 12:15 am, Kram <[EMAIL PROTECTED]> wrote:
>
> > > Does Java have pointers? I have been trying to get a definitive answer
> > > using Google and half the sites say that Java has Pointers the other
> > > half say no.
>
> > > I have found on the Sun website that Java does not have Pointers.
> > > Which really answers my question, but if references can be thought of
> > > in similar fasion, what is the difference between the two.
>
> > > I would like it very much if someone could clearly identify for me the
> > > difference between Pointers and References.
>
> > > And the million dollar question: Why, if Java does not have pointers,
> > > can you get a NullPointerException?
>
> > > Thanks for the help.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
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/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to