Basic components of the Java language
1. Keywords
Keyword concept: A word that is given special meaning by Java.
Features: The expression is English lowercase.
The Java language is a strongly typed language that defines specific data types for each data and allocates different sizes of memory space in memory.
1. Keywords for defining data types
Basic data types (four classes of eight):
Integer type: byte short int long floating-point type: float double
Character Type: Char Boolean: Boolean
BYTE: Value range -2^7 ~ 2^7-1 ( -128~127)
Short: Value range -2^15 ~ 2^15-1 ( -32768~32767)
int: Range of values -2^31 ~ 2^31-1
Long: Range of values -2^63 ~ 2^63-1
Float: Single precision, 4 bytes in memory
Double: dual precision, 8 bytes in memory
Char: Value range 0~65535
Boolean: Only True and false two types
Note: integer default data type: int decimal default data type: Double
Reference data type:
Class (classes) interface (interface)
void for functions that represent no return value type
2. Keywords for defining data type values
True (True) False (false) null (NULL)
3. Keywords for defining Process Control
Judgment: If else, switch case, default
Loops: For, while, does while
Continue loop: Continue end loop or select structure: Break
Returns: Return
4. Keywords used to define access rights modifiers
Private (privately) protected (protected) public
5. Keywords for defining classes, functions, variable modifiers
Abstract (abstract) final (final) static (static) synchronized (synchronous) enum (enum)
6. Keywords used to define the relationship between classes and classes
Extends (inheritance) implements (Implementation)
7, to define the establishment of instances and reference instances, to determine the key words of the instance
New (build instance) this (current reference) Super (parent class reference) instanceof (Judging object type)
8. Keywords for exception handling
Try (check exception) catch (Catch Exception) finally (final execution)
Throw throws: Two throws an exception, but uses a different location
9, for the package of keywords
Package (Create packages) import (Import package)
10. Other modifier keywords
Native (local)
STRICTFP (Strict float point, precision float)
Transient (variable modifier, which declares an instance variable, is not serialized when the object is serialized)
Volatile (type modifier, used to decorate variables that are accessed and modified by different threads)
ASSERT (assertion, which can be thought of as an advanced form of exception handling, captures the assumptions we make in our code)
Note :main is not a keyword, but it is a name that is recognized by the virtual machine.
Second, identifiers
Some of the names that are customized in the program.
Made up of 26 letters of the alphabet, the number 0-9, in accordance with _ $ composition.
rules for defining legal identifiers:
1, the number can not start.
2, can not use keywords.
Note: The case of identifiers is strictly distinguished in Java. In the name of the time, in order to improve the reading, to try to make sense.
Name specification in Java:
Package Name: All letters are lowercase when multiple words are composed.
· Xxxyyyzzz
Class name Interface name: When multiple words are composed, the first letter of all words is capitalized.
· Xxxyyyzzz
Variable name and function name: When multiple words are composed, the first letter is lowercase, and the second word starts with the first letter of each word capitalized.
· Xxxyyyzzz
Constant name: All letters are capitalized. For multiple words, each word is connected with an underscore.
· Xxx_yyy_zzz
3. Notes
This one's in front.
Dark Horse programmer--java Basic Grammar (i)