Overview and classification of basic Java language data types

Source: Internet
Author: User

Why are there data types

The Java language is a strongly typed language that defines specific data types for each data.

Different sizes of space are allocated in memory

Classification of data types in Java

Basic data types

Reference data type

Basic data type Classification (class 4, type 8)

Integer type

Byte occupies one byte

Short occupies two bytes

int occupies four bytes

A long occupies eight bytes

Floating point Type

Float occupies four bytes

Double takes eight bytes

Boolean type

Boolean

Theoretically occupies one-eighth bytes, but Java does not explicitly specify his dih

1 classDemo1_datatype {2      Public Static voidmain{3 4         byteb =10;5          Shorts = 20;6         Longx = 40;7         Longx = 88888888L;//The default value is int, and the range of values above int will be error, plus L or l8         floatf = 1.2f;9         DoubleD = 5.4;//the default type for decimals is double, and float is followed by F or FTen      One System.out.println (b); A System.out.println (s); - System.out.println (i); - System.out.println (x) the  -}

Overview and classification of basic Java language 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.