Differnce between C and Java returning an Object reference/pointer
In C we know that the memory allocated locally inside a function will vanish when the function returns
The caller of the function will get a pointer to the array.Although the pointer points a garbage unknown location since the array was local, it has now been destroyed.
Now I have a doubt the same thing works in Java
public String getName()
String name="Sumit"; //name here is local as above;memory allocated for the object locally
The caller of the method will correctly get the String returned.
What is the difference in the mechanism of returning pointer in C and reference in Java?
Hope I m made my point clear.
Eagerly waiting for reply.