If I declare an int (or any primitive type) within a method in Java, is that memory freed the moment the function returns, or does it have to hang around until the garbage c
Primitives are allocated on the stack, so their memory is freed the moment the function returns.