Variable, data type and type conversion, variable data type conversion

Source: Internet
Author: User

Variable, data type and type conversion, variable data type conversion

Objective: To master basic java syntax knowledge

1 variable

Variable is the amount in change, and the value in the variable is changed. in java, you must declare the variable when using the variable, and declare the variable name when declaring the variable, A variable name must be a sequence of letters or numbers starting with a letter. The length of the variable name is unlimited. When naming a variable, only one word is in lowercase. If there are more than two words, the first word is in lowercase and the first letter of the other words is in upper case. The variable name cannot use keywords in java.

2 Data Type

Integer 2.1

Java is a strongly typed language, which means that a type must be declared for each variable. There are eight basic types in java, four of which are Integer type and two floating point type, one character type.

Data Type: (1) Basic data type (2) Reference Data Type

Basic data types: numeric, char, and boolean)

Numeric: INTEGER (byte, short, int, long), floating point (float, double)

(2) reference data types: class, interface, and array

Logical boolean

Boolean data can only be set to true or false. The value cannot be 0 or an integer other than 0 instead of true or false.

Text char

A character constant is a single character enclosed in single quotes. It adopts the unicode encoding format. One character occupies two bytes.

INTEGER (byte, short, int, long)

Char occupies 2 bytes
Short from-32768 to 32767
Int from-2147483648 to 2147483647, a total of 10 digits
From-9223372036854775808 to 9223372036854775807, a total of 19 characters long

Three Forms of Integer constants in java

Decimal INTEGER: for example, 13,-204,0.

Octal INTEGER: must start with 0, for example, 014.

Hexadecimal number: it must start with 0x or 0X, for example, 0X14.

Float and double)

Java floating-point type constants can be expressed in two forms

Decimal number format: for example, 3.45.

Scientific Notation: for example, 2.34e2

 

Related Article

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.