1. Overview and use of constants
What is a constant: its value cannot be changed during program execution
Categories of Constants in Java:
Literal constants
Custom Constants (Object-oriented section)
Classification of literal constants
The contents of a string constant enclosed in double quotation marks
integer constant all integers
Decimal constant All Decimals
Character constants are enclosed in single quotes, with only a single number, a single letter, or a single symbol
Boolean constants are special, only true and false
Empty constant Null (number)
2, what is the system:
In the system: is the carry system, is a kind of carry-out method stipulated by people. For any kind of binary--x, it means that the number operation at a certain position is every x in a bit. Binary is every two in one, eight into the system is every eight into a, decimal is every ten into one, Hex is 16 into one.
The representation of different data in the system:
The binary data representation:
Made up of 0, 1. Start with 0b (b can be uppercase or lowercase) (JDK1.7 version can indicate binary)
Data representation of octal system
by 0,1,... 7 composition. Start with 0
Decimal Representation of data
by 0,1,... 9 composition. Integers are decimal by default
Hexadecimal representation of data
by 0,1,... 9,a,b,c,d,e,f (both uppercase and lowercase). Start with 0x
Fast Conversion Method:
8421 yards and features:
8421 yards is the Chinese mainland, 8421 yards is the most commonly used in BCD code. In this encoding method each digit two value code 1 is represents a fixed value, each bit of 1 represents the decimal number to add up, obtains the result is it represents the decimal digit.
Original code anti-code complement:
Original code:
is the binary fixed-point notation, that is, the highest bit is the sign bit, "0" means positive, "1" is negative, and the remaining bits represent the size of the value.
Inverse code: The inverse code of positive number and its original code phase
3. Overview and format of variables:
Variable: The amount of the value that can change within a range during the execution of a program
4. Overview and classification of data types
Integer type
Byte takes one byte-128 to 127
Short occupies two characters -2^15~2^15-1
int accounted for four bytes -2^31~2^31-1
Long is eight bytes -2^63~2^63-1
Floating point Type
Float accounts for four bytes -3.403e38~3.403e38 single precision
Double is eight bytes -1.798e308~1.798e308 double precision
Character type
Char occupies two bytes 0~65535
Boolean type
Boolean
Examples:
An overview of the ASCII code table
Remember three values:
' 0 ' 48
' A ' 65
' A ' 97
+ is called a string connector in the presence of a string
System.out.println ("5+5=" +5+5);
System.out.println (5+5+ "=5+5");
Char data type
char C = 97;0 to 65535
Characters in the Java language char can store a Chinese character? Why?
OK. Because the Java language uses Unicode encoding. Each character in the Unicode encoding occupies two bytes. Chinese is also accounted for two bytes
Therefore, characters in Java can store a Chinese character
5. Basic usage of arithmetic operators:
Classification of operators
Arithmetic operators, assignment operators, comparison (relational or conditional) operators, logical operators, bitwise operators, and trinocular (meta) operators are: +,-, *,/,%,++,--
Precautions:
The + number has three functions in Java, representing a positive sign, adding operations, and string connectors
Dividing integers can only get integers. If you want a decimal, you must change the data to a floating-point number type
Gets the quotient of the division operation,% gets the remainder of the division operation
operator
When the left absolute is less than the right absolute value, the result is left
When the absolute value on the left is equal to the right or multiple of the right, the result is 0
When the absolute value on the left is greater than the absolute right, the result is the remainder
The symbol for the result of the% operator is only related to the left, not to the right
Any positive integer%2 result either 0 or 1 can be used as a toggle condition
The use of arithmetic operators + + and--:
The role of the + +,--operator
Self-plus (+ +) self-decrement (-) operation
+ +: Self-added. +1 of the original data
--: self-reduction. 1 of the original data
Basic usage of the assignment operator:
Basic assignment Operator: =
The data on the right is assigned to the left.
Extended assignment Operator: +=,-=,*=,/=,%=
+ = Add to the left and right, then assign to the left.
Basic usage of relational operators and their considerations:
What are the relational operators (comparison operators, conditional operators) such as: ==,!=,>,>=,<,<=
Precautions:
Whether your operation is simple or complex, the result is a Boolean type. "=" cannot be written as "=".
Java language Basics