1. Stack memory is used to store some basic types of variables, arrays, and object references; heap memory is primarily used to store some objects.
2. Static variable: The variable is statically modified, and the instance variable is a non-static modified variable.
3. The difference between a static variable and an instance variable:
1) A static variable is initialized as the class loads, it can have only one in memory, and the JVM allocates memory only once, while instances of all classes share static variables that can be accessed directly through the class name.
2) The instance variable is as an instance, and each time an instance is created, an instance variable is generated, which is die with the instance.
4. Static method:
The static modification method is called a statically method and can be called directly through the class name. Because it already exists at the time of class loading, it does not depend on any instances, so the static method must be implemented and cannot be an abstract method.
Heap memory vs. stack memory in Java