Knowledge Summary
1. Variables: The amount of content that can change within a certain range during a program run.
2. How to use variables:
A) One step:
Data type variable name = data value;
b) Two steps:
Data type variable name;
Variable name = data value;
3. Identifiers: See name and Meaning. Class name Capital of each word (camel); variable name the first word in lowercase, beginning with the first letter of the second word.
4. Data types (basic types and reference types), the basic types are divided into:
A) integer type: Byte, short, int, long
b) Floating-point type: float, double
c) Character type: Char
d) Boolean type: Boolean
5. Operator: a symbol that operates on a constant or variable.
6. Expression: An equation that is connected with an operator.
7. Arithmetic operators:
A) Arithmetic: +-*/
b) modulo operation:% (see remainder only)
c) String connection: Any data type and string concatenated together, are
String result
d) Self-increment decrement operator, no difference before and after use, but mixed
There are significant differences in use
I. Before + +, first add after use
II. After + +, first use after add
8. Assignment operators:
A) Basic: =
b) Composite: + = = *=/=%= A + = 3 as a = a + 3
9. Comparison operators:> < >= <= = =! =
10. Logical operators:
a) and &&&
b) or | | |
c) also or ^
d) No!
One. Scanner keyboard input three steps:
A) Guide package: Import Java.util.Scanner
b) Created: Scanner sc = new Scanner (system.in)
c) Use:
I. Get int value: int num = Sc.nextint ();
II. Get string: String str = Sc.next ();
Java Foundation day02