Java Data types

Source: Internet
Author: User

Java data types include basic data types (built-in data types) and reference data types.

The basic data types are: integer: Byte,short,int,long float: double,float boolean type: bool character type: Char

Reference data types include: classes, arrays, interfaces, enumerations

Differences between the base data type and the reference data type:

If it is a basic data type variable, the JVM allocates a stack space for the variable, and the stack space is stored in the variable's contents

If it is a variable of the reference data type, the JVM allocates a stack space to the variable pointer to the address of the pointed content, and allocates the heap space to the contents of the variable.

The following example illustrates this point,

int a=2;

int b=3;

System.out.println (A==B);

String C=new string ();

C= "123";

String D=new string ();

D= "123";

System.out.println (A==B);

System.out.println (A.equals (b));

D=c;

System.out.pringln (C==d);

Output:

True

False

True

True

Java Data types

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.