OutOfMemoryError:
Thrown when Java is running out of memory and cannot allocate any more memory in the heap for the object
StackOverflowError:
The stack space lives at the top-end of the address space and the heap lives at the bottom-end of the address space. As stack grows, it grows downwards. As heap grows, it grows upwards. So there is a potential that the two can collide and when that happens, you get a StackOverflowError thrown. Typically happens when you call some methods recursively (that keeps going-and-going).
Thrown when Java is running out of memory and cannot allocate any more memory in the heap for the object
StackOverflowError:
The stack space lives at the top-end of the address space and the heap lives at the bottom-end of the address space. As stack grows, it grows downwards. As heap grows, it grows upwards. So there is a potential that the two can collide and when that happens, you get a StackOverflowError thrown. Typically happens when you call some methods recursively (that keeps going-and-going).