Java Data types

Source: Internet
Author: User

Java basic type    has not written a blog for a long time, have forgotten the original intention to register the blog; The basic types of data in   java are: basic data types and reference data types, not much for this;  Let's talk about where the data types in Java are stored     where the base data types are stored, depending on where the base type is declared:         1. When a base data type is declared in a method, The variable name and value are stored in the Java stack;                In the method declare basic type data:                    example: int  a = 10                  &NBS P  ①  declare a reference to a variable named a in the stack;                     ②  to find out in the stack The literal value is 10 address, if not on the opening a deposit literal is 10 address;                     ③  The variable is named a References to addresses with a literal value of 10;          2. The base data type is declared in the class when it is stored in heap memory;                     ①  The basic data types declared in the class are stored in the method area when the class is loaded;            &NBS P        ②  generating Java.lang.Class objects representing this class from the Java heap, access entry for this data as a method area;                     ③ static keyword-decorated data belongs to the class itself , stored in the method area;                     ④ final keyword-modified data represents the invariant, stored in a constant pool ;          3. Basic data type wrapper class:                  &NBSP ;  ① integer i = 10; The declaration process with i = 10.                      ② integer i = new Integer;   data 10 is the;   reference data type stored in the heap must be lost stored in the heap?         1. Special String class                     Example: string str = "abc";                   ①  to declare a reference to a variable named str in the stack;            &NBSP ;      ②  Find a String object with "ABC" in a constant pool, and if not, create a string object that stores a value of "ABC" in a constant pool;                   ③  references str to string Object "abc";                   ④ when declaring string str1 = " ABC ", the constant pool already has an" ABC "object, so str1 directly points to the address of ABC;                   ⑤STR = str1, number of references According to type comparison, the address of the app is;            NOTE: String str = "ABC" did not create or create an object         2. He quotes types                   STIRNG str = new String ("abc");      &N Bsp            ① declare a reference to a variable named str in the stack;                &NBSP ;  ②  Create a String object in the heap "ABC";                   ③  Checks if there is a string object "ABC" in the constant pool, and if it does not create a string object in the constant pool that stores a value of "ABC";                    ④ link The string Object "ABC" in the heap to the string object "ABC" in the constant pool, you can use the Intern method to return references to objects in the constant pool;                   ④ the reference to STR to the string object "ABC" in the heap; &nBsp       NOTE: string str = new String ("abc") creates one or two objects;

Java data type

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.