Simple summary of Java data types

Source: Internet
Author: User

Simple summary of Java data types

One: The Java data types are divided into two main categories: the base data type and the reference data type.

Basic data types:byte, short,int,long,float ,double,char,boolean eight.

Reference data type:

1: Except for the basic data type, it is a reference data type.

2:API class:String,File

3: Custom class:Test01 ...

4: array:int [],String []

Two: Basic data types

1: Classification

data type

bit )

data type

bit

value range

byte

-128~127

< P align= "Center" >char

16

' ~ " uffff "

Short

16

-32768~32767

Float

32

/

Int

32

-231~231-1

Double

64

Long

64

-263~263-1

Boolean

1

True/false

2: Conversion of byte numbers

1TB = 1024GB 1GB = 1024MB 1MB = 1024KB ( kbytes )

1KB = 1024Byte 1Byte = 8bit

Three: Data type conversions

in the the conversion of data types in Java is stricter than the C language, and when casting, it is necessary to take into account the specific data range and the degree of influence on subsequent operations.

For expressions with multiple types of variables participating in the operation, the final value will be consistent with the data with the highest data type precedence.

int x = n,char ch = x; system error, cannot small to large, source data type priority is higher than target data type

int x = n, char ch = (char)x; cast, need to consider the subsequent effects

Four: Reference data types

Objects are reference data types.

The assignment is therefore required to be assigned using the keyword new call constructor, but the String class can be assigned directly with the assignment operator "=".

Five: Assignment with '= =' Operation

1: Assignment Operation

1): The assignment between the base data types is actually a copyof the value,

2): The assignment between reference data types is actually the delivery of the virtual address, and the process of the address transfer also transfers the value of the address, sharing.

Example: Assignment of a basic data type

Public class Test01 {

Public Static void Main (string[] args) {

int a = 111;

int b = 222;

int C = b;

A = b;

System. out. println (the value of "a" is: "+a);

System. out. println (the value of "B" is: "+b);

System. out. println ("C's value is:" +c);

System. out. println (the value of "a" is: "+a);

}

}

The value of the result of A is: 222 B is the value of: 222 C is: 222 A value is: 222

2:= = operation

determine the virtual address, when the address is exactly the same, the return value is 'true', otherwise 'false'

Simple summary of 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.