1, Keywords: Each programming language has some reserved words, used to define the language, these words to the compiler has a special meaning, and not as an identifier, which is the language of programming keywords.
Abstract, Boolean, break, Byte, case, catch, char, class, const, continue, default, do, double, else, extends, assert, final, Finally, float, for, Goto, if, implements, import, instanceof, int, interface, long, native, new, STRICTFP, package, private, Protected, public, return, short, static, super, switch, synchronized, this, throw, throws, transient, try, void, volatile, While
Const, Goto can not be used in Java, true, false, NULL is not a keyword, but they cannot use identifiers, have special meaning to the Java compiler.
2. Identifier: System pre-defined identifier and user custom identifier.
System pre-defined: Keywords
User-defined: variable, constant, method name, property name, class name, parameter name, package name
Identifier naming rules: Identifiers cannot be keywords or true, false, NULL, can contain letters, numbers, underscores, dollar signs, the first character of an identifier must be a letter, an underscore, a dollar sign, an identifier is case-sensitive, and is unlimited in length.
3. Data type: Basic data type and reference data type
Basic data types: Byte (1 bytes, 8 bits), short (2 bytes, 16 bits), int (4 bytes, 32 bits), long (8 bytes, 64 bits), float (4 bytes, 32 bits), double (8 bytes, 64 bits), Chat (2 bytes, 16-bit), Boolean (indeterminate, true, false)
Reference data types: classes, arrays, interfaces
High-level languages control memory by controlling data types.
Basic data types have a fixed range of representations that are not affected by the platform.
When writing a class in Java, we are creating a new data type.
4, variables: In essence, a variable is a small area in memory, we use the variable name in the program to access the region, so each variable must be declared before use.
Two steps to declare a variable: give the variable a name and indicate the type of data stored in the variable
Variable declaration: Data type variable name variable value
Variable naming rules: see name and meaning; consists of letters, underscores, dollar characters, numbers, letters beginning, case sensitive, length unlimited; hump rules (conventional)
5. Basic data type
Integral type: Byet, short, int, long
Float type: float, double
Character type: Char
Boolean Type: Boolean
When performing mathematical expression operations in Java, there are automatic promotion rules:
All byte, short, char type will be promoted to int type; if one of the operands is long, then the result is long; if one of the operands is float, then the result is float type; if one of them is a double type, Then the result of the calculation is double type.
Long type after adding l,folat after adding F.
The integer default is int, and float type defaults to double.
Data type conversion principle: Big turn small to make the conversion (), little turn big automatic turn.
String type: In Java, each of the basic types to be concatenated with string Jiangbei is automatically converted to a new string object. A string object is immutable.
6. Constants
Declare constants with the keyword final
Format: Final data type constant constant value
Constants must be initialized, and a constant cannot be changed once it is determined.
The general situation of constant life is all uppercase, easy to identify.
7. Operators and expressions
Operator Precedence:
Pre + + 、——, increment or decrement occurs immediately, Post + + + 、—— occurs after the variable in the statement is used
Trinocular Operator: (boolean expression)? X:y
Java annotations: Single-line comments, multiline comments, text annotations
Summary of Java Basic syntax