Java Lesson two, Java Foundation 2

Source: Internet
Author: User

Key Words: words that are given special meaning in Java have a special purpose. identifiers:Consists of a letter, a number, an underscore (_), a dollar sign ($), cannot begin with a number, cannot be a keyword in Java, a reserved word, a case-sensitive, or a name meaning. variables: Essentially, a variable is actually a small area of memory that represents storage space for storing constant data, declare and re-use the value first Syntax: variable-type variable-name = variable-value, naming specification is the same as identifier. the first letter of the variable name is lowercase and the first letter of the other word is capitalized. constants:            * Allow assignment only once, no change is allowed during program run* Syntax: final constant name = value* The use of constants in the program can improve the maintainability of the Code* Constant names generally use uppercase charactersData type:JAva is a strongly typed language, and data stored in Java is of a type. 1*, basic data type (native data type, the data itself is stored)* Numeric type:--integer type; *byte, 1 bytes -128-127*short,2 bytes -32768-32767*int 4 bytes*long 8 bytes--floating-point *float 4 bytes must end with F*double 8 bytes* Character type: Char 2 bytes* Boolean: Boolean 1-byteThe reference data type (object data type, the data address is stored, and is typically created with new)* Classes (Class), interfaces (interface), arrays ([])specification of the use of variables;                    *: Variables are declared before use (local variables must be assigned first)*: The variable can be initialized simultaneously when used*: Only one value can be assigned at a time in a variable, but multiple times may be modified. the variable defined in the *:mian () method must be assigned before it can be output*: Variables within the same scope cannot be defined repeatedlydata type conversions:       1, automatic type conversion:* Target type is compatible with source type* Destination type is greater than source type2, coercion type conversion:* Syntax: (data type) values* Forced type conversion may result in loss of dataOperator:Operator:1, arithmetic operator:+ Plus-minus * multiply/divide% modulo + + self-increment-subtract + string concatenation++a, the first self-increment and then assign value. A + first assignment and then self-increment2, assignment operator:= + = = *=/=%= &= |= ^= <<= >>= >>>= ~= 3, comparison operator : = = Equal ! = Unequalthe operands on both sides can be numeric and reference types> < >= <= instanceofthe operands that support only the left and right sides are numericinstanceof---Judge the relationship of an object to a class--can only be used for reference data typesfeature: The result of the operation is either True or FALSE, 4, logical operator : & with | or! Non-^ xor&& Short circuit with | | Short circuit or short circuit function, high execution efficiencydifference between & and && : &: Regardless of what is on the left, the right side is involved in the operation. &&: Short circuit with, if the left is false, then the right side does not participate in the operation. | and | |  The difference: | Both operations on both sides                       || Short circuit or, if the left is true, then the right side does not participate in the operation.   5, ternary operator: logical value? Expression 1: Expression 2if the logical value is true, the expression 1 is executed, whereas the expression 2 is executed.

Java Lesson two, Java Foundation 2

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.