Data Types in Java

Source: Internet
Author: User
Tags float double

In Java, Data types is classified into and categories:

1. Primitive Data Type

2. Non-primitive Data Type

There is 8 primitive data types:

Char boolean byte short int long float double

8 Primitive can classfiied into 4 groups;

Group 1:integer

byte: It is 8 bit integer data type. Value range from-128 to 127. Default value Zero. Examplebyte b=10;

Short : It is a bit integer data type. Value range from-32768 to 32767. Default value Zero. Exampleshort s=11;

int: It is a-bit integer data type. Value range from-2147483648 to 2147483647. Default value Zero. Exampleint i=10;

Long: It is a bit integer data type. Value range from-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. Default value Zero. Examplelong l=100012;

Group 2:floating-point Number

float: It is the + bit float data type. Default value 0.0f. Examplefloat ff=10.3f;

Double: It is a bit float data type. Default value 0.0d. Exampledouble db=11.123;

Group 3:characters

Char: It is a bit unsigned Unicode character. Range 0 to 65,535. Examplechar c=‘a‘;

Group 4:boolean

This group represent boolean , which are a special type for representing True/false values. They is defined constant of the language. Exampleboolean b=true;

2) non-primitive (Reference) Data Type:

A reference data type is used to refer to an object. A reference variable is declare to being of specific and that type can never are change. We'll talk a lot more about reference data type later in Classes and Object lesson.

Data Types in Java

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.