0

Why there is no pointer in Java?

Pointer is one of the important tool in C/C++ programing language. Also, Its very important in program optimization too. But, I read there is no pointer in Java, Why is that ?

4th Dec 2016, 10:33 AM
Ramesh Neupane
Ramesh Neupane - avatar
2 Antworten
+ 3
Java have a robust security model , and using memory access via pointer it's not really safe. (plus, you need a lot more memory for in-run time checks)
4th Dec 2016, 10:42 AM
Nahuel
Nahuel - avatar
+ 2
Pointer arithmetic is unsafe, references are safer - especially during garbage collection - and Java is intended to be portable (architecture differences on pointer sizes). Here's a nice discussion: http://stackoverflow.com/a/2629758/3981745 There are exceptions but they break the JVM's mission.
4th Dec 2016, 11:27 AM
Kirk Schafer
Kirk Schafer - avatar