Java manages memory using the heap and stack. Garbage collection automatically deallocates memory used by objects that are no longer referenced, preventing memory leaks.