Java basic learning note _ basic syntax 1

Source: Internet
Author: User

1. Character delimiter set
Unicode used in Java (Uniform Code, universal code, single code)
2. identifier
1) Definition: in Java, the character sequence used for naming various variables, methods, classes, and other elements becomes an identifier.
2) Naming rules:
* Uppercase/lowercase English letters, numbers 0-9, _, and $ are 64 characters in total;
* It cannot start with a number.
* It cannot be the same as the Java keyword.
3) Naming rules:
* Class and interface: each word is capitalized;
* Variables and Methods: lowercase letters and other words;
* Constant: All words are in uppercase. Multiple words are separated by _, for example, max_value.
3. Notes
1) Explain the program code, which is not involved in program execution;
2) category:
* Single line comment ://
* Multi-line comment :/**/
* Document notes :/***/
3) Purpose: annotation description text and debugging code;
4. hexadecimal
Binary: Dual-entry
Octal sequence: Indicates each octal sequence, starting with 0.
Hexadecimal: The hexadecimal format starts with 0x or 0x.
5. Data Type
1) Data types include basic data types and reference data types;
2) Basic data types: 4 categories, 8 Types
* INTEGER: byte (1 byte), short (2 bytes), INT (4 bytes), long (8 bytes)
* Floating point: Float (4 bytes), followed by f or F, for example, 2.3f; double (8 bytes)
* Character: Char (2 bytes)
* Boolean: True, false; the size is not clearly defined.
* The default Integer type is int; the default floating point type is double.
3) The operation is data type conversion.
* Conversion rules: the data types with small capacity and large capacity are calculated. By default, the data types with large capacity are converted:
* Byte, short, char-> int-> long-> float-> double
* Byte and short cannot be converted to each other. byte can be directly assigned to short. However, byte, short, and Char are converted to the int type before calculation;
* When you convert a data type with a large capacity to a data type with a small capacity, you must add a forced conversion character, which may reduce the precision or cause overflow. Pay attention to this when using this character;
* When multiple types of data are mixed, the system automatically converts all the data to the one with a large capacity and then computes the data;
6. Constants
1) integer constant: All integers;
2) decimal constant: All decimal places;
3) Boolean constants: True, false;
4) character constant: marks a number (0-9), letter or symbol with single quotation marks;
5) String constant: identifies one or more characters with single quotes.
6) null constant: NULL; describes a non-existent point;
7. Variables
1) is a region in the memory used to store data;
2) Definition Format: data type variable name = initialization value;
* Value assignment: byte B = 1;
* Assignment Method 2: byte B1; b1 = 1;
3) Scope: from the definition position of a variable to the inner braces of the variable;
8 Operators
1) Arithmetic Operator: +-*/% + + --
% (Modulo operation): the symbol of the operation result depends only on the symbol of the number before %, and the symbol of the subsequent array can be ignored.
++ --: ++: First, and then, and then, ++, then, first, and then, in addition; --
2) assignment operators: =, + =, and so on;
Byte B = 1; B + = 2; + = when assigning values to B, the forced conversion operation is automatically completed;
3) comparison operator: = ,! =,>, <, >=, <= The result is Boolean (true, false)
4) logical operators:
* & True: True;
* | Same-false indicates false;
* ^ The same is false, and the difference is true;
*! ! True is false
* Short circuit and: & run on the right side regardless of the social security result;
& The value is false on the left and not executed on the right;
* Short circuit or: Same short circuit and similar
5) bitwise operators
* <Left-shift low position 0, which is equivalent to multiplying the power of 2
*> The right shift is equal to the number of power pairs divided by 2. the symbol bit is not involved in the shift.
* Bitwise Operations <> are faster than multiplication and division operations, but you must pay attention to accuracy issues, such as: 42> 2 is equivalent to 42/2 (2) = 10.5
* >>> The unsigned right shift is basically the same as the right shift. The difference lies in the absence of digits on the left to fill in 0.
9. Conditional Operators
1) Format: Condition expression? Expression 1: expression 2
* If the condition is true, expression 1 is returned;
* If the condition is false, expression 2 is returned;

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.