+ 6
Why java does not supprt call bh reference and pointers??
4 Respostas
0
No pointers supported in Java, which (may?) would be needed for that (unless a compiler workaround, maybe).
So, why no pointers?
There are some hacky tool included in Java, so you can do similar stuff, like allocate bytes, and cast them to be a certain object of a type. These unsafe stuff included in the mysterious sun.misc.* package, and highly NOT RECOMMENDED to use. Java developers (I mean Oracle) use the package for themselves, but professional programmers started to use it in special cases. Oracle dislikes this, and wished to remove the utility, then the community answered like "Hell, NO!"
It is really a complex question, because Java is said to be one of the safest programming languages, and so, the manual use of pointers is - as all if us know - can be dangerous, allocating memory (and freeing it) "by hand" is the main reason of that.
You can read more on the current situation here:
https://adtmag.com/blogs/watersworks/2015/08/java-9-hack.aspx?m=1
All that is said, reference parameters (like ref params in C# or pointers in C++) are completely unsupported in Java, afraiding of illegal pointers, I think (pointing to memory, which was allocated, but not aready). For that, you must use reference of objects, which wraps values, exactly like in your code.
+ 6
Because java virtual machine manage memory for program itself and programmer can only give hint to deallocate memory but using pointers memory management is much in the hand of programmer.
+ 5
Do check out the attached program with the question...
0
Similar thread:
https://www.sololearn.com/Discuss/111165/?ref=app