Java Beginner Java language main knowledge point three

Source: Internet
Author: User

1. Data types in Java

Data type: base type and reference type

Basic type: Numeric, character, Boolean

Numeric: integer types and floating-point types

Reference type: Class, interface, array

Basic data types

Four class/Eight class basic types are defined in Java

Boolean----Boolean

Character type----Char

Integer type----byte,short,int,long

Floating-point type----float,double (all basic types in Java have a fixed storage range and the amount of memory space they occupy without being affected by the specific operating system, thus ensuring Java portability)

2. Integer type

Type takes up storage space storage range

BYTE 1 byte-128 ( -2^ (8-1)) ~-127 ( -2^ (8-1)-1)

Short 2 bytes -2^ (16-1) ~-2^ (16-1)-1

int 4 bytes -2^ (32-1) ~-2^ (32-1)-1

Long 8 bytes -2^ (64-1) ~-2^ (64-1)-1

Float 4 bytes

The Java-language integer constant defaults to int, to declare long can be added ' L ' long i=3l

In Java, floating-point constants default to double type, to declare a constant float type such as float i=3f

Boolean type for logical operations, generally for program flow control

Boolean type data only allows values of true and False

3. Conversions between basic data types are divided into four types

Automatic type conversions: small-capacity types are automatically converted to large-capacity data types (char,byte,short,--long--float--double,) with the addition of a forced conversion character

Forcing type conversions

The Boolean type cannot be converted to any of its data types

    

    

            

Java Beginner Java language main knowledge point three

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.