Basic Java Syntax: Data Type-general Linux technology-Linux programming and kernel information. For details, refer to the following section. Java is a strictly typed language. This means that each variable must have a declared type. Java provides eight basic types. Six numeric types (four integers, two floating point types), one character type, and one boolean type. Java also provides large numeric objects, but it is not a Java data type.
1. Integer:
Definition: A number without decimal digits. A negative number is allowed.
Type: Java provides four integer types:
Int 4 bytes-2,147,483,648 to 2,147,483,647
Hort 2 bytes-32,768 to 32,767
Long 8 bytes-9,223,372,036,854,775,808 L to 9,223,372,036,854,775,807 L
Byte 2 bytes-128 to 127
2. Floating Point Number:
Definition: number that contains the decimal part.
Category: Java provides two floating point numbers:
Float 4 bytes +-3.40282347E + 38F (6 ~ 7 valid decimal digits)
Double 8 bytes +-1.79769313486231570E + 308 (15 valid digits)
Note:
1) The float type value has a suffix F. If there is no suffix F, the default value is double. The suffix D can also be used for values of the double type.
2) When these numbers encounter a value range error, it will occur (Overflow), and Underflow will occur when the image is divided by zero ).
3. Character Type:
Definition: single quotes are used to represent char constants,
Note:
1) double quotation marks indicate a string, which is an object of Java and is not a data type.
2) the char type indicates the characters in the Unicode encoding scheme.
Unicode can contain 65536 characters at the same time, and ASCII/ANSI can contain only 255 characters. It is actually a subset of Unicode. Unicode characters are usually expressed in hexadecimal encoding. The range is between '\ u0000' and '\ uff. \ U0000 to \ u00FF represents ASCII/ANSI characters. \ U indicates that this is a Unicode value.
3) in Java, in addition to representing characters in the \ u format, you can also use the code-changing sequence to represent special characters.
\ B backspace \ u0008
\ T Tab tabulation \ u0009
\ N newline \ u000a
\ R hard press enter \ u000d
\ "Double quotation marks \ u0022
\ 'Single quotes \ u0027
\ Backslash \ u005c
4) theoretically, Unicode characters are used in Java applications and small applications, but whether they can be truly displayed depends on the browser and operating system used, the operating system is the most fundamental.
4. boolean type:
The boolean type has only two values: false and true. Friends who have used other programming languages must be familiar with them.
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