The java virtual machine uses two kinds of memory , the stack(for method variable ) and heap (for objects) each time an object is created its done in heap ..which the garbage collector free.
..upon each function calls function variables are held in stack which is destroyed when function returns..if you dig deeper then there is static variable and classes which is held in neither stack or queue ..
..upon each function calls function variables are held in stack which is destroyed when function returns..if you dig deeper then there is static variable and classes which is held in neither stack or queue ..