In this article we will understand the basics of how memory works in Java. We will try to understand in a simple way how memory works in form of stack and heap. By the end of this article we will have better understanding on stack and heap and how memory…