Data types for "DAY2" Java

Source: Internet
Author: User

Java four class eight basic data types

First class: integer byte short int long

Type II: float float double

Class III: Logical Boolean (it has only two values desirable true false)

Class Fourth: Character Char


After studying the contents of the fourth day, you can find

Data that can be allocated directly in the stack is the base data type.

Reference Data type: is a reference to the data in the stack, but his object is in the heap .


Number of bytes:

Boolean Boolean 1

byte byte type 1 range -128~127

Char character type 21 characters can store a Chinese character

Short Quick-Integer 2

int integer Type 4

float float type (single precision) 4

Long length shaping 8

Double dual precision type (double) 8


The default integer type in Java is type int, and the default float is a double-precision floating-point double.


Automatic conversion of basic data types

Byte->short,char, int, long

Double, float

float, int

Double, long

Because the down conversion does not lose precision, the upward conversion may lose precision




This article is from the "Yehomlab" blog, make sure to keep this source http://yehom.blog.51cto.com/5159116/1772593

"DAY2" 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.