Camel-style nomenclature and underline method:
Camel-named: Each logical breakpoint in the name has a capital letter to mark;
Underline: Each logical breakpoint in the name has an underscore to mark;
Camel nomenclature: The first word begins with a lowercase letter, the first letter of the second word is capitalized or the first letter of each word is uppercase;
Small Hump Method: In addition to the first word, the first letter of the other words capitalized;
Large Hump method: Capitalize all words, often used for class names, namespaces, etc.;
Java syntax is case sensitive;
All content in a Java application must be placed in a class;
Definition of class name:
The name must begin with a letter and can be followed by any combination of letters and numbers;
The length of the basic No limit;
Case sensitive;
You cannot use the Java reserved word (the keyword that comes with it);
Standard naming convention: A noun that starts with a capital letter, and if it consists of multiple words, the first letter of each word should be capitalized;
Attention:
Letters: Includes A-Z, A-Z, $, _, and Unicode characters that represent letters in a language (the first two letters in English, and the characters that represent letters in other national languages);
Number: 0-9, and any Unicode character that represents a number in a language;
The source code must have the same name as the public class;
Code Run Process:
Compile: By command "Java file name. Java", compile the source file, get a bytecode file "file name. Class", in the same directory as the source file;
Run: Run the compiled source file (the bytecode file) from the command "Java file name", and the Java virtual machine will execute from the main method of the specified class;
In order for code to execute, a main method must be included in the source file of the class;
The access modifier for the main method must be public;
The code enclosed in {} is called a block;
Three types of annotations:
: Shortcut keys: Check the code (can be a single line, or multiple lines), CTRL +/(add and delete comments are all using this shortcut);
/** * *: can automatically generate documents;
/* */: Cannot nest; shortcut: Check, add Comment: Ctrl + SHIFT +/; Remove Comment: Ctrl + SHIFT + \;
Java is a strongly typed language: that is, before a variable is used, a data type must be declared for the variable;
data type:
is divided into basic data types and reference data types;
Basic data type classification (eight types):
integer: Byte, short, int, long;
float type: float, double,
character type: char;
Boolean: boolean;
Span style= "font-family: italics; font-size:16px "> Reference type classification:
arrays, String type (string), object;
java, the number of bytes occupied by all numeric types is platform independent. This way, the code will not have many problems when porting the platform,
Long integer value plus suffix l;
hexadecimal value prefixed with 0x;
octal value plus prefix 0;
Span style= "font-family: italics; FONT-SIZE:16PX "> binary plus prefix 0b; (Java 7 start)
float type of value plus suffix f ; (JDK 5.0 can use hexadecimal to represent floating-point values)
double type value plus suffix D ; (JDK 5.0 can use hexadecimal to represent floating-point values)
Three special floating-point values that represent overflow or error conditions:
Positive Infinity: There are three constants in a double and float boxed class that represent these three values;
Negative Infinity: There are three constants in double and float boxed classes representing these three values;
NaN (not a number): There are three constants in the double and float boxed classes representing these three values;
The method of judging whether a number is Nan:
with x = = NaN, no, the result is always false;
With Double.isnan (x); to judge;
Java does not have any unsigned type (unsigned);
Floating-point values do not apply to financial calculations that prohibit rounding errors, because there is a problem of precision confusion, and the BigDecimal class should be used to achieve financial calculations;
char type:
use single quotes, not double quotes;
escape character: remember several commonly used;
Encoding table knowledge:
definition of variable name:
names must begin with a letter and can be followed by any combination of letters and numbers;
length is basically unlimited;
case-sensitive,
cannot use Java reserved words (keywords that comes with it);
Recommendation: Use the Hump naming method to define;
Note:
: Includes A-Z, A-Z, $, _, and Unicode characters that represent letters in a language (the first two represent letters in English, and characters that represent letters in other national languages);
number: 0-9, and any Unicode character that represents a number in a language;
The variable must be declared;
variable declaration must be displayed after initialization before it can be used;
variable can be done simultaneously;
Use the final modified variable to indicate that the variable can only be assigned once, and once it is assigned, it cannot be changed again;
Customary, the constant name uses all uppercase;
Two constants:
Normal (local) constant:
Use the final modified variable;
defined within a method, only this method can be used;
Class (Global) constants:
variable with static final decoration;
is defined outside the main method;
Operator:
Arithmetic operators: + 、-、 *,/,% (for remainder operation, to divide the number of operands), + + 、--;
Increment and decrement operator: its operator cannot be a numeric value;
Relational operators:
Boolean operator: Note the "Short circuit" mode;
Bitwise operators
Ternary operators:
Java-Basic syntax