Java Execution Order:
A field or method that is modified by static is run immediately when the class is loaded, calling the constructor method of the parent class (because Super ()), loading the field, and finally executing the statement
Tools to use EditPlus:
Configuration details:
The principles of compiling and running:
Compile: When the mouse cursor is in which file, the tool compiles the file, finds the file by the file name, and compiles the contents of the file.
Running: in which file the current target is located, the tool will find the corresponding. class file according to the file name and then run it.
Note: single-line Comment:
Start with//End with line: Show the programmer, explain the role
Multi-line Comments:
/**/can write multiple lines.
Documentation notes:
/** start */end, can write multiple lines. differs from multiline annotations: Documents can be generated from the Javadoc tool
Basic syntax:
1.Java source file, no content, compile without error, do not generate bytecode files, compile the contents of the file compile
2.class decorated class name +{}: The source file writes the content: called a class can generate bytecode files, bytecode files are class names.
3. If a class does not have a main method, the program will have no entry, compile, or run.
4. The main method does not write the content, there is no output statement, no output of any content, compile run will not error.
Note: The method is written in the struct body of the class.
A function statement is written in the structure of the method.
5. In one source file, you can write multiple classes, it is recommended to write only one
Note: In a class, you can write a class, called a class in a class.
6.java Program Case Sensitive
7. A class can be decorated with public, the public-decorated class must exist in a file with the same source file name as the class name, inconsistent compilation error
Separator, keyword, modifier delimiter
Semicolon (;): The Division of a statement, the end of a sentence, as we use the period.
Curly braces ({}): Represents a block of code, is a whole, curly braces are to be used in pairs.
square brackets ([]): used when defining arrays and accessing array elements.
Parentheses (()): Widely used, specifically used in detail.
Dot (.): used when a class and an object access its members.
Space (): Divides a whole sentence into a few paragraphs, the number of spaces is not limited.
A space between the general words can be
Note: The English symbol must be in the half corner.
Key words
Keywords: In fact, in the design of Java when the words given special meaning
For example, China change Byte class
features : All letters all lowercase
Modifier
For Java, classes, variables, methods, construction methods, etc... To give special meaning to the modified content.
There are class modifiers, carriage variable modifiers, method modifiers.
Identifier:
Naming something in Java: Playing the role of the logo
Rules:
Must start with the English a-z,a-z,$,_, and the numbers (numbers cannot be started)
Specification:
Class first letter Capitalization
method, variable name: first Letter Lowercase
Multiple words make up each word with the first letter capitalized
Take some meaningful words.
Data type Description:
Binary: Binary 0b begins with octal 0, beginning with hexadecimal 0x.
Integer data type:
A byte short int long.
The data type limits the types of values that can be used in the village, range.
Integer value: The default type is int type
Represents a long type of data that needs to be added at the end of the data
Floating-point data type:
Float double
For a decimal, the default type is double type
Want a decimal to represent the float type, you need to add f after the data
Floating-point type data, represented in a computer is not an exact data, but a data that is infinitely close to that data
Java provides a class: A larger certificate: You can use the BigInteger
More precise floating-point: you can use BigDecimal
Reference type:
The string type is a reference data type, a string: double quotation marks, and a string of symbols.
String is a class that Java has written.
There is no difference between a class written by yourself and a class written in Java, a class, a reference data type
Strings are used together with the + string concatenation function
Boolean Data types
The value is only two true false, and 0 1 is not used to indicate
Use of data types simple introduction variables
The amount that can change, the value can change
Can be called a container: Loading data
Can only be turned once, if the next reload, will be the last cover
To define the syntax for a variable:
Assign values at the same time as defined:
Data type variable name = value
Define the post-assignment value first:
Data type variable name;
Variable name = value;
Data type conversions:
Automatic data type conversions
Forcing data type conversions
Core Knowledge: Automatic type conversion
Small data types that turn large data types, called automatic type conversions
Forcing type conversions
Large data types are converted to small data types, called forced type conversions
Conversion Details:
Auto Convert: 1.long float double. Two operation data, one type, and the result will be converted to the corresponding type
2.byte,short,char,int operand, if it is two, the final result is of type int
Cast: If the size of the storage space is the same, but the data types represent inconsistent ranges of values, it is also necessary to force type conversions
Size of data type: Determine the size of the data type by the storage space of the data type!
Forced-Reload Syntax:
Data type variable name = (data type) value or variable;
Forced type conversion, must be aware of the range of values, only makes sense! Otherwise the data is lost, and it doesn't make sense to convert
just look at the container without looking at the value
Constant escape character
Constant: A known value, a value that does not change
Escape character: Java Specifies that special symbols have special meanings and are symbols for special purposes.
①\r means accept keyboard input, equivalent to press ENTER;
②\n indicates a line break;
③\t represents the equivalent Table key tab,;
④\b means backspace key, equivalent to back space key;
⑤\ ' denotes single quotation marks;
①\ ' means double quotation marks;
②\\ represents a slash \.
Variable:
Can be seen as a container: loaded things, features, can only be installed once, the next time will cover the last time. The type of data that a qualifying variable can store
Syntax of the definition
Assigning values at the same time as defined
Data type variable name = value;
Define and assign values first
Data type variable name;
Variable name = value;
Variable classification
Member variable: A variable written in the struct of a class, called a member variable
Characteristics:
1. Can not attach the initial value: According to the data type has a default value;
2. member variables, values will always exist
Local variables: Variables written in a method are local variables
Characteristics:
1. Initial values must be attached before use
2. The role of a variable only works in the process of method execution, in order to assist the method to complete the function exists
The method ends with the value of the variable.
Variable scope
1. Internal curly braces can: Use the variables in the outer curly braces!
2. Member variables are also called global variables
Practice
Class _16lianxi{ //class the modifier of the keyword class _16lianxi classes name Class _16lianxi{} This is a class public static void Main (string[] args) {// Main method The entry case of the main method program is sensitive to write fixed int a = +; The definition variable is an int variable named a assigns an initial value int b = five; Define the variable to be an int variable named B to assign the initial value int c = A; Define the variable to be an int variable named C to assign the initial value a = b; Assign the value of B to a B = C; Assign the value of C to B System.out.println ("a=" +a);//Function Statement display a=25 System.out.println ("b=" +b);//Function Statement display b=15 }}
Java execution and basic syntax