Two core mechanisms of 1.java
Java Virtual machine---(CPU with byte-code instruction)---*.class
Java compiler---bytecode---------the virtual machine runs
Garbage collection mechanism (GC)
Features of the 2.java programming language (a purely object-oriented, interpretive language):
1, Object-oriented
1, Package
2, inheritance
3, polymorphic
2, security
3, cross-platform
3. Configure Environment variables:
Java_home
Classpath
Path
4.public class Name {
public static void Main (string[] args) {
SYSTEM.OUT.PRINTLN (111);
}
}
Places to be aware of:
The class name should be consistent with the file name (exactly the same)
5. Identifiers:
Any place that needs your name is called an identifier.
Java programming is strictly case-sensitive
The name of the identifier cannot be duplicated with the keyword
Reserved words: Goto CONST, etc.
6. Rules:
Identifiers are alphabetic (case), _, $, and cannot start with a number
Code specification: Hump Naming method
String EmpName
getElementById
7. Four classes eight kinds:
Integer type
BYTE 2 of 8 Square (256)-127 to 128 this is the value range, total 256 number of memory accounted for 1 bytes
Short 2 of 16 square memory 2 bytes
int 2 of the 32-square-memory account 4 bytes
A long 2 of the 64-time memory occupies 8 bytes
Floating point Type
FLOAT----Valid Digital 7-bit (single-precision floating-point type) 4 bytes in memory
Double----A valid number is 16 bits (double) in memory, which accounts for 8 bytes
Boolean type
Boolean (only two values, True, False) 1 bytes in memory
Character type
char (single quote) 2 bytes in memory
Strings string (double quotes)
The assignment of a variable char c = ' a '; char c = ' word '; char c = 98; Asii a char c = ' \ n '; char c = ' \u0061 '; Unicode
Define an integer variable by default to long L = 123456; Long L = 88888888888L; Need to be in the back plus L, uppercase L, according to its length to determine;
Type conversions:
Double float long int char short byte
When a char short byte is evaluated, the value defaults to int
8. ^ (XOR operator)
Example:
X is a binary number 0101
Y is the binary number 1011
The result is x^y=1110
0^0=0;0^1=1;1^0=1;1^1=0
The result is 0 only if the bit of the comparison is not at the same time as the result is 1
That is, "the same is 0, the difference is 1".
9.false&&true/false: ... (short-circuit operator) The first expression is false, the second expression does not execute
int a=5; int b=3; A < b && ++b? "1": "2"
++b: First self-increment and then assign value
b++: First assignment and then self-increment
System.out.println (b);
The output has a value of 3,&& as a short-circuit operator, A<b is not true, and subsequent executions are not performed.
Bitwise operator:>> (shift right) << (left) >>> (unsigned Right shift) right, left empty bit filled with 0
5-->101 5 converted to binary 0000 0101
5<<2 left shift two bit 0001 0100
-5>>>2
To convert a negative number to binary: 1. Find out the binary of 5
2. After taking the inverse, that is 1 to change 0;0 1; Draw 1111 1010
3. Anti-code plus 1 is called the complement 1111 1011
Move right to 0011 1110
Example:
A<<4 refers to moving the binary of a to the left by 4 bits. such as a=00000011 (decimal 3), left 4 digits after 00110000 (decimal 48);
Left shift is: Discard the highest bit, 0 the lowest bit;
A=15,a>>2 00001111 to the right of 00000011 (decimal 3);
For signed numbers, when you move right, the sign bit moves along with it. When positive, the highest bit is 0, while negative, the sign bit is 1;
3+5+ "a"--->35a
String Join operator: + (as long as there is a string in the entire expression, the entire result is a string)
Note: In the output, as long as there is a parameter is a string, the entire output is a string
Ternary operator (expression) (Trinocular operator): Boolean value 1: Value 2
Binary conversion
Java First lesson