I’m just picking up java. I tried something but it won’t compile:
int[] arr = methodThatReturnsIntArray();
But this one works:
int[] arr = null;
arr = methodThatReturnsIntArray();
Why is it so? Isn’t that array variables are just references (or pointers)?
Many thanks!
Both of them are correct and should not give compilation error provided that the
methodThatReturnsIntArray()is returning a valid integer arrayfor example: