Home > Java > javaTutorial > body text

Briefly introduce the code examples of heap area, method area and stack area in Java

黄舟
Release: 2017-05-21 10:14:49
Original
2238 people have browsed it

The following editor will bring you an article that discusses the Java heap area, method area and stack area in detail. The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor to take a look.

Heap area:Only stores classobjects, shared by threads;

Method area: Also called static storage area, which stores class files and static data, shared by threads;

Stack area: Storage method local variables, basic type variable area, execution environment context, operation instruction area, threads are not shared;

class A {
  private String a = “aa”; //a在堆区
  public boolean methodB() {
    String b = “bb”; //b在栈区
    final String c = “cc”; // c在栈区
  }
}
Copy after login

The above is the detailed content of Briefly introduce the code examples of heap area, method area and stack area in Java. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!