Java Notes 1: java notes
If you want to write database-related software, you can study JDBK in depth. If you want to work on program software related to network information exchange, you can learn XML; if you want to develop and design large network applications, you can learn Java EE. If you want to engage in Iot-related embedded development and design, you can learn Java ME; if you want to develop web programs, you can learn JSP.
Java platform:
Javase javaee javame
Java environment construction:
Jvm: -- Java virtual machine, -- execution Program
Jre: -- java Runtime Environment, including jvm and standard class library
Jdk: -- java development kit, including development tools and jre, javac java
Jvm ---> jre --> jdk
Environment variable settings:
PC-right-click Properties-> advanced settings-> Environment Variables
--> System variable --> Path
Java programming and running steps:
1. Create a. java File
2. Compile the source code file
3. Compile the source code file javac source code file name. java
4. Run the java class name of the class file
Data Type:
Basic Type: byte short int long float double char boolean
Reference Type: Class array interface Enumeration
Conversion between data types:
Automatic conversion: Small ---> large
Byte short char --> int
The floating point type appears in the operand and the result is of the floating point type.
Forced conversion: Large ---> small (type)
Boolean is not involved in conversion.
Variable:
Data type variable name = value;
OPERATOR:
Arithmetic Operator: +-*/% + + --
Assignment operator: = + =-=/= * = % =
Comparison OPERATOR: >>=<==! = True/false
Logical OPERATOR: & |! ^ & | True/false
Operator: (boolean expression )? Expression 1: expression 2;
Identifier: Class Name, variable name, Method Name
Composition: letters, numbers, _, $
Rule: keywords in java cannot start with a number.
Class Name: uppercase letters
Variable name: The first word is lowercase, and the second start is the first letter of each word.
Method Name: The first word is lowercase, and the second start is the first letter of each word.
Note:
Single Row ://
Multiple rows :/*....*/
Documentation:/**... */javadoc -- html
String: Reference Data Type
The string type can be connected to any type of data +
Returns a string.
Eg: String s = "abc" + 100;
Branch statement
If Branch
If (boolean expression ){}
If () {} else {}
If () {} else if () {}... else {}
If () {if (){}}
Switch Branch
Switch (expression) {// byte short char int String Enumeration
Case Constant Value :...
Break;
....
Default:
Break;
}
Loop statement:
While do/while
While: 0-n, first judge and then execute
Do/while: 1-n, first executed and then judged
While (){}
Do {} while ();
For (initialization; condition; increment ){}
Method declaration:
Modifier return value type method name (parameter list ){
Execution statement
Return value;
}
Class and object:
Class: a set of objects with the same attributes and behaviors.
Object: an instantiation of a class.
Class name {
Attribute
Method
Constructor
}
Object Declaration: new
Encapsulation: private the attributes and behaviors of objects to provide public access.
Set/get
Public
This: indicates the reference of the current object.
1. It is used to solve the problem of duplicate names of local variables and instance variables.
2. Call the overload Constructor
Constructor:
1. The method name and class name are the same
2. No Return Value Type
3. Called when executing the new statement
This (parameter list); must be placed in the first line of the non-Comment row of the constructor
Array: a set of data of the same type.
Save batch data
The data stored in the array has subscripts, starting from 0.
Obtain the array length: array name. length
Exception: out-of-bounds, null pointer
For (element type variable name: array name ){
Statement
}
String [] args: receives command line parameters
Data Type... variable name: Array