Yes. You can get away with more in C/C++, pass around and exchange pointers to functions (as is custom with a qsort compare), interpret types as you like (cast away a const) and of course perform arithmetics over their memory addresses. Java only offers pass- reference-by-value, for qsort compare callbacks you need to go through an interface (Delphi and C# gets around this by introducing delegates) and swap methods just aren't possible (C# gets around this by offering additional modifiers such as "ref","output" and "params"). Pointer arithmetics is dangerous business and I doubt if very many miss that, much of the same functionality you get with java.nio.ByteBuffers.
/Casper On Nov 12, 5:22 am, Kram <[EMAIL PROTECTED]> wrote: > Yeah thats sort of what I meant to say, the references in Java are > safe, but C style pointers are less reliable but have more > functionality, is this also safe to say? > > On Nov 12, 3:13 pm, Casper Bang <[EMAIL PROTECTED]> wrote: > > > A reference *points* to a place on the heap. If, how and when they are > > ever moved depends on the garbage collector. To avoid fragmentation, > > sweeps are made and objects can be moved to different generations and > > the references are then updated. Only sure thing to never be moved, > > are references to PermGen. The garbage collector will either "stop the > > world" while it does its thing or use advanced concurrent algorithms > > to perform its duty. From your point of view and for all practical > > purposes, you won't ever notice a thing. > > > /Casper > > > On Nov 12, 4:46 am, Kram <[EMAIL PROTECTED]> wrote: > > > > Ok no problem, so what about the other thing I said, am I on the right > > > track? > > > > On Nov 12, 1:11 pm, Weiqi Gao <[EMAIL PROTECTED]> wrote: > > > > > Kram wrote: > > > > > 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??? > > > > > When Casper said "Java has pointers. But ..." what he's saying is that > > > > "Nah, they aren't really pointers." > > > > > So, no. > > > > > -- > > > > Weiqi Gao > > > > [EMAIL PROTECTED]://www.weiqigao.com/blog/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
