I saw this sentence in some matrials:
"In Java, simple data types such as int and char operate just as in C."
I am wondering that actually they are different in Java & C++?
In C++, simple variables like the primitives in Java are assigned a memory address as well, so these primitive types in C++ can have a pointer as well. However primitives in Java are not assigned a memory address like Objects are.
Am I correct?
Thanks!
Almost.
In java primitives are assigned memory as well, but this happens internally and you cannot get the reference.
Thre reason was to provide security on memory management.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With