Primary knowledge of java-variables, data types and operators. 2

Source: Internet
Author: User

One, data type

1, underlying data type

Integral type:

Byte (8bit)

Short (16bit)

Int (32bit)

Long (64bit)

Floating point type:

Float (32bit)

Double (64bit)

Character type:

Char

Boolean type:

Boolean

2, reference type

String type

String

3. Data type Conversion

(1) Automatic data type conversion:

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

Rule 2: Conditions for automatic type conversions are met.

(2) Forcing data type conversions:

Example

  

Two, variable

1, declare the format of the variable:

Data type variable name = value of variable;

2, examples of each type:

3, naming rules for variable names:

(1) The variable must begin with a letter, an underscore "_", or a "$" symbol;

(2) A variable may include a number, but cannot begin with a number;

(3) except "_", "$" symbol, can not include any special characters;

(4) You cannot use keywords in Java, such as: int,class,new, etc.

4 various types of assignment need to pay attention to

(1) A value of type char is required to be ' caused;

(2) The value of string type is to be caused by ""

(3) Boolean value can only be true, false both;

Three, operator

1, assignment operator

= Assign the right value to the left

Example

2, arithmetic operator

Subtraction to take the remainder

+   -    *   /    %

3, relational operators

> Greater than

< less than

>= greater than or equal to

<= less than or equal to

= = equals

! = does not equal

Primary knowledge of java-variables, data types and operators. 2

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.