Pointers in Java Are there pointers in Java? The short answer is "no, there are none" and this seems to be obvious for many developers. But why is it not that obvious for others? Difference between reference and pointer As Brian Agnew summarized on stackoverflow there are two major differences. There is no pointer arithmetic References do not "point" to a memory location Missing pointer arithmetic struct in C the memory allocated for the array contains the content of the structures one after the other. If you have something like struct circle { double radius; double x,y; } struct circle circles[6]; it will occupy 6*3*sizeof(double) bytes in memory (that is usually 144 bytes on 64 bit architecture) in a continuous area. If you have something similar in Java, you need a class ( until we get to Java 10 or later ): class Circle { double radius; double x,y; } and the array Circle circles[6];
Read full article from Pointers in Java | Java Deep
No comments:
Post a Comment