+ 4

Why we are using pointer in C and C++ but not in java?

13th Aug 2017, 7:06 AM
Safinaz Sayed
Safinaz Sayed - avatar
5 ответов
+ 5
Because C++ is meant to be a language where you can interact with the hardware with low level features, yet still have higher level features such as classes. Java on the other hand favors safety. Java uses references, which are safer than pointers and get the job done for Java's purpose. It should be noted that C++ also supports references. And they should of course be used instead of pointers when pointers aren't needed.
13th Aug 2017, 7:37 AM
aklex
aklex - avatar
+ 2
got it but the question is why we can not use it in java.
13th Aug 2017, 7:18 AM
Safinaz Sayed
Safinaz Sayed - avatar
+ 2
I have an article related to this question https://javax0.wordpress.com/2016/01/06/pointers-in-java/
13th Aug 2017, 7:38 AM
Manual
Manual - avatar
+ 1
Edit I believe reference types are the closest thing to pointers in Java
13th Aug 2017, 7:28 AM
Manual
Manual - avatar
0
actually java also uses pointers but unlike c they use it internally.
13th Aug 2017, 7:33 AM
shobhit
shobhit - avatar