Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
32 views1 page

Java Memory Management Basics

Core Java memory management involves stack and heap memory, with the JVM primarily accessing stack memory. The main method must be static and public for the program to run, and local and global variables are defined based on their scope. Objects are created within the main method to link stack and heap memory for accessing non-static variables or methods.

Uploaded by

Saurabh Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views1 page

Java Memory Management Basics

Core Java memory management involves stack and heap memory, with the JVM primarily accessing stack memory. The main method must be static and public for the program to run, and local and global variables are defined based on their scope. Objects are created within the main method to link stack and heap memory for accessing non-static variables or methods.

Uploaded by

Saurabh Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Core Java:

*Class is made to allocate memory.

*Memory is divided into two parts: Stack memory and heap memory.

*Program is run by JVM and JVM can access stack memory only.

*Jvm call main method to run program.

*If ‘static’ keyword is not written in main function, JVM won’t be able to access heap memory hence
program won’t be able to run.

*JVM would be able to access the stack memory from outside only when keyword ‘public’ is written.

*Method’s written type always would be void.

*You may need to store any type data in main method and there may be multiple values need to be
stored in that hence we define it as String type of array. We write String because any type of data
can be stored in String and in array we can store multiple values.

* We may need to store more than one value that’s the reason we put Array’s operator[].

*Such variable which has written in any method is called local variable. Variable which has been
written outside of method but inside the class called Global variable.

There are two type of global variable: Static global variable and instance global variable. If Static is
not prefixed with variable then it goes into heap memory which is called instance global variable.

*If jvm need to access data from heap then we would need to link stack memory with heap memory
and we make object for the same.

*If any variable or method is non static then we need to make object to run the program.

*Object is made inside the main method only.

You might also like