Computer program: A collection of ordered instructions written to allow a computer to perform certain operations or solve a problem.
1>java SE: Standard Edition
Fundamentals and core of 1.Java technology
2. Primarily used to develop desktop applications
2>java EE: Enterprise Edition
1. Provides a complete solution for enterprise-class application development
2. Many websites are developed using Java EE technology
JDK, Java SDK (Java Development Kit)
JRE is the Java Runtime Environment (Java Runtime Environment)
JVM, which is the virtual machine (Java virtual machines)
Java SE API, is the Java System Core Class library (available, including network, IO, GUI, etc.)
Java language Programming Considerations
1. Case sensitive, pay attention to case sensitivity
2. After each code is written, the following semicolon ends with a ";"
3. In the code, the appearance of parentheses is generally paired
Java syntax structure
public class file name {
public static void Main (String []args) {
System.out.println ("content");
}
}
Knowledge points
1.Java Project directory Structure
SRC directory: Storing source code in project
The jar package for the Java Runtime Environment of the JRE System Library
2. Create a new source file
SRC directory, new selects class and generates Java source files
Running programs in 3.myeclipse
Right-click in the code area->runas->java application
After the program runs, the output will be displayed in the console (console)
Escape Character Description
\ n Moves the cursor to the first pane of the next line
\ t moves the cursor to the next horizontal tab position
The single-line comment begins with//, primarily explaining the single line of code, or variable
Multiline comment/* Comment content * * Multiple lines of code can be commented at once
Document Comments/** Comments * * Description of classes (Class), as well as description of the method and the contents of the comments generate the information of the API documentation
Java Coding Specification
1. Class names are decorated with public
2. Write only one statement in a row
Use and location of 3.{}
4. Code Indentation
Code emissions in MyEclipse
Shortcut key Ctrl+shift+f
Java data types are divided into
1. Basic data types
2. Reference data types (classes and objects learned later)
8 Basic data types
1. Integer type: Byte, short, int, long
2. Floating-point number type: float, double
3. Character type: Char
4. Boolean Type: Boolean
Data type variable name; int money;
Variable name = value; money=1000;
Data type variable name = numeric int money=1000;
Data type
1. The default type of integer type is int
2. Define a long type of data, you must add L or L after the data
3. The default type of floating-point number type is double
4. Define a float type of data, you must add F or f after the data
5.double, you can add D or D after the data, usually omitted
6.char denotes the character type, and the data is placed in the value when the value is assigned
7.String is a string type, and the data is placed in the value when the value is assigned
Variable name = (1. Letter 2. Underline 3.$ symbol) + (any number of 1. Number 2. Letter 3. Underline 4.$ symbol)
Variable Naming conventions:
A short and clear indication of the function of a variable, usually the first letter of an initial word is lowercase, and the first letter of the word is then capitalized
A variable declares a variable and assigns a value before it can be used
Scope of the variable
Starts at the defining variable place and ends after the current "}". If the variable is out of scope, it will be retracted.
Assignment operators
Assign the right value to the left variable
Variable name = expression;
An expression is a combination of symbols (such as numbers, minus signs) and operands (such as B, 3, and so on)
Automatic type conversion (hermit type conversion): From small type to large type can be completed automatically
Coercion of type conversions: from large types to small types requires a cast character, which can cause loss of precision or overflow
Basic Data type Conversions
Char....>byte>short>int>long>float>double
From left to right small type to large type, can be automatic type conversion, from right to left large type to small type, need to force type conversion
Join operations of the same type (may require automatic type conversion)
Returns the same type (may occur overflow and down overflow)
Byte, short, char, three types in Java is the representation (false) the bottom is in accordance with the INT operation
The role of "+"
+ represented in arithmetic operators as addition operations;
In a string, you can use it to concatenate strings, and you can also connect to variables of other data types.
Common relational operators
1.>,<
2.==,!=
3.>=,<=
The role of relational operators: used for comparison operations
Result of comparison: Boolean type
Boolean (Boolean)-type value
1. True (True)
2. False (False)
Console input Scanner
Steps to implement the console input data:
The first part: On the class Guide package, import Java.util.Scanner;
Second part: Create Scanner object, Scanner scan=new Scanner (system.in);
Part III: Methods of invoking objects, receiving data entered in the console
Scan.next ();//Receive String data
Scan.nextint ();//Receive integer type data
Scan.nextdouble ();//Receive floating-point type data
Self-increment (decrement) operator
1. Self-increment (decrement) operator: ++--
Is the operator that can increase (decrease) The current variable self
2.i++, after + +, first the value of I as the entire expression of the value and then add I 1
3.++i, first + +, add I to 1 first, then the value of I as the value of the entire expression
Precedence of Operators
Highest priority: parentheses, i.e. ()
Lowest: assignment operator
Precedence order: Arithmetic operators > Relational operators > Logical operators
Select structure
Basic IF-selection structure
if (condition) {
code block
}
logical operators
Operator Expression Description
&& conditions 1&& Conditions 2 Only two conditions at the same time true result is true
|| Condition 1| | Condition 2 As long as two conditions have one true and the result is true
! ! When the condition is true, the result is false. When the condition is false, the result is true
operator precedence and order;! > Arithmetic operators > Comparison Operators >&&>| |
If Else selection structure
if (condition) {
Code Block 1
}else{
Code Block 2
}
Multiple if selection structure
if (score >=80) {
Code 1
}else if (score >=60) {
Code 2
}else{
Code 3
}
If selection structure
if (condition 1) {
if (condition 2) {
Code 1
}else{
Code 2
}
}
Compare switch and multiple if selection structures
The same point: all structures used to handle multi-branch conditions
Different points:
Switch selection structure
Can only deal with the condition of the equivalence criterion, and the condition must be an integer variable or a character type variable
Multiple if selection structure
There is no restriction on switch selection structure, especially when a variable is in a continuous interval
Loop structure
While loop structure
while (loop structure) {
Looping operations
}
Features: first judgment, then execute
Random Number (0~9)
int random= (int) (Math.random () *10);
Arrays.sort. (array name);
System method
Grammar
public static void main array copy
int Srcpos
Object Dest
int DESTPSS
int length
Parameters
SRC---original array
Sropos---Starting position in the original array
Dest---target array
Destpos---The starting position in the target data
Length---The number of array elements to copy
Arrays method
Grammar
int [] copy of (int []original,int newlength)
Parameters
Original The array to be copied newlength the length of the copy to be returned
Java (i)