Java Data types

Source: Internet
Author: User

Data type

A) number ( int(integer), double-precision floating-point double (decimal))

b) Character type (char), storing a single character

c) string character (string), storing multiple characters

Boolean Data types

Boolean: A value of TRUE or False

Assignment: The boolean variable name =true or false or an expression;

Data type Conversions ( for numeric types )

1, divided into 2 major categories:

numeric type (int, double),

Non-numeric type (character ', String ', Boolean type bool)

2. Data type Conversion classification

A) automatic type conversion--"P41 page"

I. Rule 1: If one operand is of type double, the entire expression can be promoted to a double type

Ii. Rule 2: Conditions for automatic type conversions are met.

Two types are compatible: numeric types (int and floating-point double)

Destination type is greater than Source type: Double type can hold int type,(int-->double"enlarge transform")

b) Coercion type conversion: Target type variable name = (target type) variable or expression;

"A value of type double, saved to the INT type variable"

int variable name =(int)a value or variable of type double;

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.