Java Memory analysis

Source: Internet
Author: User

Note:

variables : In essence, a variable is actually a small area of memory (stack) that uses variable names to access the area. Therefore, each variable must be applied (declared) before it is used, and then it must be assigned before it can be used.

Divided by the declared location:

  • Local variable: A variable defined inside a method or statement block.
  • Member variable: A variable that is defined internally by a method outside of a class.
  • Note: Outside the class (outside the curly braces that correspond to the class), you cannot have a declaration of a variable.

By the data type that belongs to:

  • Basic data type variable (inside stack)
  1. Boolean type only with Ture and false
  2. The char type represents a single character, enclosed in single quotation marks.

    Example: Char a= ' a ', b= ';(characters can be letters, Chinese, symbols, etc.)

    char c = ' \u0061 ';(can be represented by Unicode encoding, two bytes per character)

    char d = ' \ n '; ' \ n ' represents a newline (you can also use the escape character ' \ ' to convert the character following it to another meaning)

  • Reference data type variables (within the heap)

Constants : Constants are represented by a string, and the values of the character and string constants are two and cannot be changed. (Use the final keyword)

Java Memory analysis

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.