Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deleting An Entire Array

Tags:

java

arrays

I have written a program for sorting an integer type array which involves the creation another array of the same size. After sorting, there is no use of the new array, so I want to completely get rid of it. So far, I've only found questions relating to the deletion of specific types of elements. Some help?

Information (if needed):
Original Array: A[n]
New Array: B[n]
B[n] has to be completely deleted.

like image 300
Graviton Avatar asked Mar 31 '26 23:03

Graviton


1 Answers

The temp array will be "deleted" (or more correctly, the occupied memory will be eligible for garbage collection) automatically whenever you leave the method performing the sorting (assuming of course that the temp array is created inside the method).

There is almost never any need for explicit memory deallocation in Java.

like image 117
Keppil Avatar answered Apr 02 '26 13:04

Keppil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!