Computer Science, asked by Priyansh1001, 1 year ago

why don't we need pointers in java ?? but we need them in c/c++

Answers

Answered by surajithere
1
It is all about dynamic memory allocation. I hope you know that, everything in a program need some space. In terms of variables you have many ways to access the values inside the variables. So, pointers are one of the way. Where you can get, put, change the value using the address of the variable's memory location. Java comes with lots of useful packages so, you don't need pointers to do the same what you need in C/C++.
Answered by siddhartharao77
3
What is a pointer:

= > It is a variable, which can store the address of another variable. 


Few points you must know about why pointers are not supported in Java:

(1) Pointer variable must require Static memory allocation, Java supports dynamic memory allocation.


(2) Pointers are very much applicable in Platform dependent languages, Java is platform independent language.


(3) Already, Java is a highly-secured programming language, So there is no use of pointers again!.


(4) Pointers can be Quite confusing, especially to new programmers. Java is a simple programming language. Therefore these two concepts were left out of java.


(5) Because Pointers are unsafe.



Hope this helps!

siddhartharao77: :-)
Similar questions