3 ms·
> I know in Java you have boxed pointer versions of primitive types, like Integer instead of int. And you can’t really have non-boxed pointers in Java, basicall
by shock 9y ago
> I know in Java you have boxed pointer versions of primitive types, like Integer instead of int. And you can’t really have non-boxed pointers in Java, basically every pointer is allocated on the heap.
That's not true. In Java pointers can very well be allocated on the stack, but the objects that they point to will be on the heap
- Rusky 9y agoIt looks like the article pretty consistently uses the phrase "the pointer is allocated ..." to mean that that's where it's pointing to.
- shock 9y agoSo the article is pretty consistently misleading/incorrect. A pointer is a data structure like any other, in fact Java is pass-by-value, the pointer values are copied when objects are being passed as function arguments.
- Rusky 9y agoTo me it seems it's just using different terminology than you expected. I've heard and used the article's version plenty of times and it generally works in context.