(Java) Second week study summary

Source: Internet
Author: User

In the Java source code, each variable must declare a type. There are two types: primitive type and reference type. The reference type refers to the object (reference to object), and the base type directly contains the value (directly contain value). Therefore, the Java data type (type) can be divided into two main classes: the base type (primitive types) and the reference type (reference types). Primitive types includes a Boolean type and a numeric type (numeric types). Numeric types is also divided into integer (integer types) and floating-point (floating-point type). There are 5 types of integers: byte short int long char (char is essentially a special int). Floating-point types have float and double. The relationship is organized like this:


Objects are dynamically created instances of a class or dynamically created arrays. The value of reference types is references to objects, whereas references generally refer to memory addresses. All objects (including arrays) support the methods defined in the object class. String literals is presented by String object.

character and string literals

Character literals in Java are enclosed in single quotes, such as ' @ ' 1 '. All UTF-16 character sets are included in the character literal. Characters that cannot be entered directly can use escape characters, such as ' \ n ' for newline characters. You can also use octal or hexadecimal notation for characters, and octal to use backslashes with 3-digit digits, such as ' \141 ' for letter A. Hexadecimal uses \u plus 4 for 16 decimal digits, such as ' \u0061 ' to denote character a. That is, by using the escape character, you can represent all or none of the characters on the keyboard. A common sequence of escape characters is:

\DDD (octal), \uxxxx (hexadecimal Unicode character), \ ' (single quotation mark), \ "(double quote), \ \ (backslash) \ r (carriage return) \ n (newline character) \f (page break) \ t (tab) \b (Back to Geff)

String literals use double quotation marks, which in string literals can also contain sequences of escape characters in character literals. The string must be on the same line or use the + operator because Java does not have a continuation escape sequence.

Java has two types (type), which correspond to the values of both data (two kinds of data values that can is stored in variable, pass as arguments and returned by M Ethods), these two data values are: primitive values,reference values. Perhaps this is easier to understand (though not rigorous), there are two types of Java variables: Primitive variable and reference variable, which store primitive value and reference value, respectively, in variables.

Null is a special type, but you cannot declare a variable to be a null type, and the only value for a null type is NULL. Null can be negative to any reference type or to any reference type. In practice, NULL is generally used as the literal value (literal), which is a literal reference type.

2. Basic type:

Java provides language-level support for basic types, which are already predefined in Java and are represented by corresponding reserved keywords. The base type is a single value, not a complex object, and the base type is not object-oriented, primarily out of efficiency considerations, but also provides the basic type of object version, the basic type of wrapper (wrapper). You can use these basic types directly, or you can construct arrays or other custom types using the base type. The base type has a definite range of values and mathematical behavior.

(Java) Second Week learning summary

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.