Jacva BASICS (II) and jacva Basics
Data Type Variable Operator
1. Data Type
Basic Type: Class 8
Integer: byte short int long
Floating Point (decimal): double float
Character: char
Boolean: boolean
Reference Type: String type
2. Variables
Essence: a space in the memory used to store various types of data.
Three elements: data type variable name variable value
Syntax for declaring variables:
I: name of the data type variable;
Variable name = variable value;
Ii: data type variable name = variable value;
3. Data Type Conversion
Automatic type conversion:
I: must be compatible with each other.
Ii: If the variable type is small, it can be automatically converted to a type with a large variable type. /* When either of the two numeric types is double
The result is automatically upgraded to the double type. */
4. Scanners
Import package:
Because the scanner class is in the java util package
Import java. util. vendor; // import the util package where the Scanner class is located
Wrote input = new partition (System. in );
System. out. print ("remind yourself of the type of data you want to enter ");
Char num1 = input. next (). charAt (0); // the first character of the char-type syntax input
5. Operators
I. Arithmetic Operators
+-*/%
Ii. Relational operators
><>==! =
Iii. assignment operator
= + =-=/= % =
Iv. logical operators
& Short circuit and | short circuit or & single and | single or! Non
V. Single Object Operator
Num ++ auto plus: num ++ = num + 1 num -- Auto minus: num -- = num-1
++ Executes the operation before the operation, and ++ performs the operation before the operation. -- Likewise