C/C++ uses pointers. Java doesn't use pointers—why?
C/C++ uses pointers. Java doesn't use pointers—why?
C and C++ use pointers, which are variables that store the memory addresses of other variables. Pointers provide direct access to memory, allowing for efficient memory management and manipulation. However, they also introduce the risk of memory leaks and segmentation faults, making them potentially dangerous to use.
Java, on the other hand, was designed to be a simpler and safer language. It was intended to be more accessible to beginners and less prone to the kind of errors that can occur in C and C++. As a result, Java does not use pointers in the same way that C and C++ do. Instead, Java uses references, which are similar to pointers but are safer to use. In Java, references allow objects to be passed by value, without exposing the underlying memory address.
Step by step
Solved in 2 steps