Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple Variables in Java & C++

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!

like image 607
user36064 Avatar asked Dec 03 '08 21:12

user36064


1 Answers

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.

like image 63
OscarRyz Avatar answered Sep 20 '22 03:09

OscarRyz