One of the Java Learning Notes: Java Basic data types

Source: Internet
Author: User

(This content is purely personal summary, if there is inappropriate, welcome readers correct!!)

Java Basic Data type:

1. Integral type

The integer data types in Java are decimal, hexadecimal, octal.

There is no need to say the decimal, and the C language in the decimal number is the same.

For example: inti=12;

Iny j=10;

int m=-1223;

Octal:

Full 8 in 1, number is 0~7,

Precede the integers with a 0 representation of the octal system,

int i=09;

int j=-012;

Hexadecimal:

Same as the hexadecimal number in C, add 0x or 0X to the front of the number

int i=0x12;

int j=0x123;

Note: The decimal, hexadecimal, octal number is based on the octal number preceded by 0, and hexadecimal number preceded by 0x or 0X.

2. Floating point type (i.e. decimal)

Single-and double-precision.

FLOAT: single-precision

The declaration of the single-precision type is, after the number is added F or f (individuals think F or F is worth the first letter of the keyword float);

such as: float i=12.01f;

float j=-23.0f;

Double: two-precision

The number that declares a double is a number followed by a D or D (the first letter of the keyword that the individual considers to be double);

However, a double type can be declared without d or D;

such as: Double i=11.11223d

Double j=112.2233d;

Note: The numeric default type for floating-point types is double!!!!

If the floating-point number is not followed by a letter, then the data is a double-precision floating point!!!!

3. Character type data

The character type is used to denote a character, enclosed in single quotation marks, such as charc1= ' B ';

Like the C language, there are special escape characters in Java, such as carriage return, newline, and so on.

4. Boolean Type (Boolean)

Use True with false to indicate true and false.

such as: Boolean a1=true;

Boolean b2=false;

5. Conversion of values

I'm not going to say much about that.

5. The identifier.

Defining identifiers is to make a person look "as the name implies", so it is best to define identifiers as the "name implies".

Identifiers begin with an English letter, consist of letters and numbers, and other characters cannot appear in identifiers.

Better than that, master. Naming rules:

A. The English alphabet is a~z,a~z, as well as ' _ ' and ' $ ';

B. Figures include 0~9;

C. Other characters cannot appear in identifiers;

D. Keywords that cannot be reserved with Java;

The E.java identifier is case sensitive.

One of the Java Learning Notes: Java basic data type

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.