Java Study Notes-2. Java identifiers and basic data types

Source: Internet
Author: User

In this section, identifiers are relatively simple and there is nothing to record. Take notes on the Basic Java data types.

Java has four basic data types:

 

1. Logical (Boolean)

The boolean type has only two values, true and false. In Java, 0/1 cannot be used to indicate true/false, just like C/C ++! 

 

2. Balanced type

Char type, useSingle quotesEnclosedLetter (cannot make string)Such as char c = 'n.

In the escape type, the special Escape Character "\". The most common escape characters are:

'\ N': newline' \ t': tab, where \ indicates escape, for example, \ "output is", \ outputs \.

 

3. Integer

 There are four types: byte, short, Int, and long.

The byte type is 8 bits, the short type is 16 bits, the int type is 32 bits, and the long type is 64 bits.

 

4. Floating Point Type

 Float is divided into two types: float and double. Float is called Single-precision, which is 32-bit, double is double, and 64-bit. Note that the default type of a decimal point (such as 1.0) is double!

 Example:

 Float F = 10.1 this will report an error during compilationBecause 10.1 is of the double type by default, it is not automatically converted to the float type.

If you want to assign 10.1 to the float type,The correct writing method is: Float F = 10.1f.

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.