JDK, JRE, JVM
1. JDK
Java SDK is the core of the entire Java, including the JRE (Java Runtime Environment), a bunch of Java tools (Javac, Java, JDB, etc.), the Java base Class library.
2. JRE
Java runtime Environment, all Java programs are running under the JRE. Includes JVM and Java core class libraries, support files, and so on.
3. JVM
Java Virtual machine, which is part of the JRE.
Work flow
The JDK's Javac compiles Java code files into Java bytecode and then hands them to Jre,jre to run these Java bytecode, parsing bytecode through the JVM, mapping to CPU instruction sets or OS system calls.
###########################################################################################
Memory mechanism
Java divides memory into two types: stack memory, heap memory
1. Stack memory
Allocate space: The basic type variable defined in the function, the reference variable of the array/object
When executing this block of code, Java allocates memory space for the variable in the stack, beyond the scope of the variable, and Java automatically frees the memory space.
2. Heap Memory
Allocate space: Object, array of new.
After the heap memory produces an array/object, it automatically defines a special variable in the stack memory, the value of which is equal to the first address of the heap memory, and the variable in the stack becomes a reference variable to push the array or object in memory, using the reference variable in the stack to access the array/object in the heap memory. When a reference in the stack does not point to a variable in the push memory, the variable in the push memory becomes garbage, but still occupies space and is freed by the garbage collector at a later indeterminate time.
###########################################################################################
Variable
1, member variables, global variables
Variables defined in the Variable definition section (the beginning of the class) are called member variables of the class, and others are called global variables. Member variables are valid throughout the class. Member variables are also divided into instance variables and class variables.
2. Instance variables
The most common member variable is not modified by static.
3. Class variables, static variables
A member variable that is decorated by the static keyword, called a class variable or a static variable.
This variable is only one in memory, and the JVM allocates memory for class variables while loading the class.
Class variables are located in the method area and are shared by all instances of the class.
can be accessed directly from the class name. class variable name. Its life cycle depends on the life cycle of the class.
4. Local Variables
The parameters of variables and methods defined in the method body are called local variables.
A local variable is only valid in the method in which it is defined.
When the local variable name is the same as the member variable name, the member variable is hidden
Access modifiers cannot be used with local variables.
###########################################################################################
Access modifiers
Private
Private access, which can only be accessed in this class, takes advantage of this permission and shows the encapsulation idea.
Default
Default access permissions, which can be accessed in a class in the same package or in a subclass in the same package.
Protected
Protected permissions, in addition to default, can also be accessed in subclasses of different packages.
Public
Public access, the most relaxed, can be accessed. Show the idea of interface-oriented programming.
###########################################################################################
Static
1, can be modified member variables, member methods, you can also form statically static code block. Represents "global" or "static", class variable, static variable.
2. As long as this class is loaded, the Java Virtual machine can be found in the method area of the runtime data area according to the class name, and can be accessed before any of its objects are created, without referencing any objects.
3. Access: Method: Class name. static method name (parameter); variable: class name. Static variable Name
4, Static code block: block, can have multiple, position can be placed casually, not in any method body, the JVM load class, according to the Order of the Declaration, the execution of these static code blocks. Each code block is executed only once.
###########################################################################################
Final
Non-abstract classes, non-abstract member methods, variables can be modified
The final class cannot be inherited, there are no subclasses, and the method of the final class is fianl by default.
The final method cannot be overridden by a class method, but can be inherited.
The final method lock prevents any inherited class from modifying its meaning and implementation
The final method is efficient, and the compiler goes into the embedding mechanism when it encounters the final method, which greatly improves the execution efficiency.
The FIANL member variable represents a constant that can only be assigned once and is no longer changed after the assignment.
Final member variables must be assigned at the time of declaration.
Final cannot be used to modify a construction method.
###########################################################################################
Abstract abstraction
Interface interface
1, a class, you can implement multiple interfaces.
2, all the methods in the interface are abstract.
Abstract class
1, a class, can inherit only one abstract class. Inheriting an abstract class, you must implement its abstract method.
2, abstract class, can not have any abstract method, can also have a common method.
3. Abstract classes cannot be instantiated.
Abstract methods
###########################################################################################
HTTP Hypertext Transfer Protocol
Characteristics
1, support client/server mode.
2, simple and fast: the client requests to the server, only need to transfer the request method, path. Common request methods are get, POST, HEAD. Each method specifies that the client has a different type of contact with the server.
3, Flexible: HTTP allows the transfer of any type of data objects. The transport type is marked by Content-type.
4, HTTP0.9, and 1.0 use a non-persistent connection: Restricts each connection to only one request, the server finishes processing the customer's request, and receives the customer's response, which disconnects the connection. In this way, the transmission time can be saved.
HTTP1.1 using persistent connections: Instead of creating a new connection for buying a Web object, a connection can transfer multiple objects.
5, stateless: HTTP protocol is a stateless protocol. A stateless protocol is a protocol that has no memory capacity for transactional processing. A lack of state means that if the previous information is required for subsequent processing, it must be re-routed, which may result in an increase in the amount of data transmitted per connection and, on the other hand, a faster response when the server does not need the previous information.
Request method
The http/1.1 protocol defines eight methods (sometimes called "actions") to indicate different ways of manipulating the resources specified by the request URI.
This article is from the "Zero Technology Road" blog, please be sure to keep this source http://zerohou.blog.51cto.com/3019528/1614998
Basic Java Knowledge