does writing
int []arr=new int[5];
and
int []arr={5,6,7,8,9};
both are allocated in heap.or first in heap(arr as reference ) and second one in static.
does writing
int []arr=new int[5];
and
int []arr={5,6,7,8,9};
both are allocated in heap.or first in heap(arr as reference ) and second one in static.
@RULEREMPIRES,
When you use int []arr=new int[5]; here an array is created of 5 integers where the value at each index is 0. Hence the value at each index won’t make a difference. Since by default the value is 0. Hence, both are allocated in heap
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.