Java basic summary, super full interview questions

Software King 2020-11-10 00:13:14
java basic summary super interview

1. static What do keywords mean ?Java Can I overwrite (override) One private Or is it static Methods ? Can I static Access to non static Variable ?

static Keyword indicates that a member variable or member method can be accessed without the instance variable of the class to which it belongs .
Java in static Method cannot be overridden , because Methods cover (override) Is based on runtime dynamic binding , and static Methods are statically bound at compile time .static Methods have nothing to do with any instance of a class , So conceptually it doesn't apply .
Not in static Access to non static Variable ,static Variable in Java Medium is Belong to category Of , it The values are the same in all instances . When class is Java When the virtual machine is loaded , Would be right static Variable to initialize ( Life and death with the same class ). Not static Variable , Only when a class is created , To allocate space ( If it's a local variable within a method , Then create when the method is called ).

2. Java The difference between interface and abstract class in
  • Interface is more abstract than abstract class , Because constructors can be defined in abstract classes , There can be abstract methods and concrete methods , The constructor cannot be defined in the interface, and the methods are all abstract methods .
  • Classes can implement many interfaces , But you can only inherit from one abstract class . If a class inherits an abstract class or implements an interface, it needs to implement all the abstract methods in it , Otherwise, the class still needs to be declared as an abstract class .
  • Abstract classes can implement an interface without providing an interface method implementation .
  • Java The variables declared in the interface are all final Of . Abstract classes can contain non final The variable of .
  • Java The default member function in the interface is public Of . The member function of an abstract class can be private,protected Or is it public.
  • The interface is absolutely Abstract , Cannot be instantiated . Abstract classes cannot be instantiated either , however , If it contains main Method can be called .( Neither abstract class nor interface can be instantiated , But you can define references to abstract classes and interface types )
  • Interface can inherit interface . Abstract classes can implement (implements) Interface , Abstract classes inherit concrete classes , But the premise is that the concrete class must have an explicit constructor .
  • Classes with abstract methods must be declared as abstract classes , Abstract classes do not need abstract methods .
    Interface can inherit interface , And support multiple inheritance . Abstract classes can implement (implements) Interface , Abstract classes can inherit concrete classes or abstract classes .
3. Processes and threads
  • process It is a dynamic execution process of a program , Each process has its own independent memory space . An application can start multiple processes at the same time ( For example, the browser can open multiple windows , Every window is a process ), A process is an executing application , A thread is an execution sequence within a process . A process can have multiple threads . Threads are also called lightweight processes .
  • A multiprocessing operating system can run multiple processes , Every process can Recycle what you need CPU Time slice , Make all processes of look like meanwhile It works the same .
  • Threads It's an execution process of a process , yes CPU Dispatch and distribution The basic unit of pai . A process can be composed of multiple threads , That is to say A process can run multiple different threads at the same time , Each thread performs different tasks .
  • Concurrent running of threads : It means that several threads run simultaneously in a process .( such as :word The spelling check and automatic capitalization of initials are word Threads in the process )
  • Threads and process The relationship is a Local and whole The relationship between , Each process is allocated a separate memory address space by the operating system , All threads in the same process work in the same address space .( Processes usually have separate memory units at execution time , And threads can share memory
  • Although multithreaded programming usually leads to better performance and user experience , But multithreading takes more CPU resources , Not friendly to other processes ( It may take up more CPU resources ), Not the more threads , The better the performance of the program , Because scheduling and switching between threads can also be wasted CPU Time . Insert picture description here
4. The life cycle of a thread

The complete life cycle of a thread goes through 5 Medium state : newly build 、 be ready 、 function 、 Blocking 、 Death .
 Insert picture description here

  • newly build state : Use new And some kind of thread construction method To create thread objects , The thread will enter the new state , The system allocates memory space for the thread object . The thread in the newly created state can call start() Method into ready state .
  • be ready state (Runnable): At this point, the thread is ready to run , Entered the thread queue , Wait for system allocation CPU resources , Once you get CPU resources , The thread will enter the running state .( Thread ready to run , It doesn't have to start right away )
  • function state (Running): Enter running in state , The thread will execute its own run() The code in the method . It's the code that the process is executing the thread .
  • Blocking state (Blocked): An executing thread , If executed suspend、join or sleep Method , Or wait for io Right to use the equipment , Then the thread will give up its own CUP Take control and temporarily suspend your execution , Go into blocking mode . Blocked threads , Unable to enter the ready queue , Only when the cause of obstruction is eliminated , The thread can enter the ready state , Reenter the thread queue and wait CPU resources , And then go ahead and do it .
  • Death state (Dead): A thread completes all work or is forced to abort ahead of time , The thread is dead .
  • sleep state (Sleeping): Threads pass through Thread.sleep( Thread sleep )、Object.wait( Thread waiting )、LockSupport.park( Thread pause ) Three ways Put a thread to sleep .
    Synchronous blocking (Blocked on Synchronization):sleep( ) Causes the thread to enter the blocking state in a certain period of time ( Lock resources will not be released )、wait( ) Put the thread in a blocked state ,( Release your own lock resources , collocation notify( ) Use )、suspend( ) Put the thread in a blocked state ( It must correspond to resume( ) Called , To get the thread back to the executable state )

wait(): Make a thread wait ( Blocking ) state , also Release the lock of the object held ;
sleep(): Make a running thread in sleep state , It's a static method , Call this method to process InterruptedException abnormal ;
notify(): Wake up a waiting thread , Of course, when this method is called , Does not wake up a waiting thread exactly , But by the JVM Determine which thread to wake up , And it's not about priority ;
notityAll(): Wake up all waiting threads , This method does not lock the object to all threads , It's about letting them compete , Only the thread that obtains the lock can enter the ready state ;

6. Thread Class sleep() Methods and objects wait() What's the difference ? Thread sleep() Methods and yield() What's the difference ?

Thread Class sleep() Methods and objects wait() Method

sleep()* Method ( Sleep ) yes * Thread class ( Thread)* Of * static state Method , Call this method to make The current thread pauses execution for the specified time , Opportunities to be implemented ( CPU) Give way to other threads , however The object's lock remains , Therefore, it will resume automatically after the end of sleep time ( Thread back to ready ).
*wait()* The method is Object Class method , call Object's wait() Method Causes the current thread to Relinquish the object's lock ( Thread pause ), Enter object's waiting pool (wait pool), Only Call the object's notify() Method ( or notifyAll() Method ) Only when you can wake up Wait for the thread in the pool to enter the lock pool (lock pool), If the thread Regain the lock of the object and you can enter the ready state .

Thread sleep() Methods and yield() Method

1)sleep() Method When you give other threads a chance to run Regardless of thread priority , So it gives low priority threads a chance to run ;yield() Method It's just Give threads of the same or higher priority to run The opportunity of ;
2) Threads execute sleep() Method to block ( blocked) state , And perform yield() Transfer in ready after method ( ready) state ;
3)sleep() Method declaration throw InterruptedException, and yield() Method does not declare any exceptions ;
4)sleep() Method ratio yield() Method ( Follow the operating system CPU Scheduling correlation ) Better portability .

7. What is a thread pool (thread pool)

In object oriented programming , Creating and destroying objects is time consuming , Because to create an object, you need to obtain memory resources or other resources . stay Java in , The virtual machine will try to track every object , In order to be able to garbage collection after the object is destroyed . therefore One way to improve the efficiency of service programs is to minimize the number of times objects are created and destroyed , In particular, some resource consuming objects are created and destroyed , This is it. ** Pooling resource technology ** Cause of occurrence .
As the name implies, thread pool is to create several executable threads in advance and put them into a pool ( Containers ) in , When needed, get threads from the pool without creating them , After use, you don't need to destroy the thread, but put it back into the pool , This reduces the overhead of creating and destroying Thread objects .
Java 5+ Medium Executor Interface defines a tool for executing threads . Its subtype, thread pool interface, is ExecutorService. Tool class Executors Face provides some static factory methods , Generate some common thread pools .
Tool class Executors Common ways to generate thread pools :

1)newSingleThreadExecutor: Create a Single thread Thread pool of . This thread pool has only one thread working , In other words, it is equivalent to the serial execution of all tasks by a single thread . If the only thread ends because of an exception , Then there will be a new thread to replace it . This thread pool ensures that all tasks are executed in the order in which they are submitted .
2) newFixedThreadPool: establish Fixed size thread pool . Each time a task is submitted, a thread is created , Until the thread reaches the maximum size of the thread pool . Once the size of the thread pool reaches the maximum, it remains unchanged , If a thread ends because of an exception , Then the thread pool will add a new thread ( Return to the thread pool ).【 Recommended 】
3)newCachedThreadPool: Create a Cacheable thread pool . If the size of the thread pool exceeds the number of threads needed to process the task , Then it will recycle some of the idle (60 Seconds do not execute task ) The thread of , When the number of tasks increases , This thread pool can also intelligently add new threads to handle tasks . There is no limit to the size of the thread pool , The thread pool size is completely OS dependent ( Or say JVM) Maximum thread size that can be created .
4)newScheduledThreadPool: Create a Unlimited thread pool . This thread pool supports the need to execute tasks regularly and periodically .
5)newSingleThreadExecutor: Create a Single threaded thread pool . This thread pool Support the need to perform tasks regularly and periodically .

If you want to use thread pools on the server , Strongly recommended newFixedThreadPool Method to create a thread pool , This gives you better performance .

8. Java The difference between the local thread and the guard thread in

java There are two types of threads in : The guardian thread ( Daemon) And user threads ( User).
j Any thread can be set as a guardian thread and a user thread , By means of Thread.setDaemon(boolon);true Then set the thread as a guardian thread ,false Set to user thread .Thread.setDaemon()
Must be in Thread.start() Previous call , Otherwise, the runtime will throw an exception .

The difference between a guard thread and a local thread

The only difference is judging virtual machines (JVM) When to leave , The guardian thread Daemon Is to provide services for other threads , If all the user sites Thread Has been evacuated , Daemon No threads to serve ,JVM Evacuate . Can also be
To understand that the guardian thread is JVM Automatically created thread ( But not necessarily ), A user thread is a thread created by a program ; such as JVM The garbage collection thread of is a guardian thread , When all threads have been evacuated , No more waste , The guardian thread will be fine , When the garbage collection thread is Java The only line left on the virtual machine
Travel time ,Java Virtual opportunity leaves automatically .

9. synchronized Keyword usage , When a thread enters an object's synchronized Method A after , Whether other threads can enter the synchronized Method B?

1)synchronized Keyword can mark an object or method as synchronous , To achieve mutual exclusive access to objects and methods , It can be used synchronized( object ) { } Define synchronization code block , Or when declaring a method synchronized Modifier as method .
2) Can't get into .
Other threads can only access the asynchronous methods of the object , Synchronization method cannot enter . Because the synchronized The modifier requires a lock on the object when the method is executed , If you have already entered A Method description object lock has been removed , Then try to enter B The thread of the method can only wait for the lock pool ( Note that it's not the waiting pool ) Lock of waiting object in .

10. sketch synchronized and java.util.concurrent.locks.Lock Similarities and differences

Lock yes JDK1.5 New ones introduced later API, And keywords synchronized Similarities and differences :
The same thing :Lock Can finish synchronized All functions implemented ;
Main differences :Lock Comparable ratio synchronized More precise thread semantics and better performance , And it's not mandatory to get a lock .synchronized Will automatically release the lock , and Lock It must be released manually by the programmer , And it's better to finally Release in block ( This is the best place to release external resources ).

11. Deadlock 、 Live lock 、 hunger ? What are the necessary conditions for deadlock ? How to ensure N Threads can access N Resources do not cause deadlock at the same time ?
  1. Deadlock 、 Live lock 、 hunger The concept of , The difference between

1) Deadlock : A deadlock occurs when both processes are waiting for the other process to finish executing before continuing . The result is that both processes are caught in an infinite wait . A phenomenon of waiting for each other caused by competing for resources , If there is no external force , They will not be able to move forward
2) Live lock : Task or performer is not blocked , Because some conditions are not satisfied , Causes repeated attempts , Failure , Try , Failure .
3) hunger : One or more threads are unable to obtain the required resources for various reasons , The state that has been unable to execute .

The difference between a live lock and a dead lock
Entities in a live lock are constantly changing , So-called “ live ”, and
Entities in deadlock behave as waiting ; It's possible that the live lock can be unlocked by itself , Deadlock cannot .

Java Causes of hunger in
1) High priority threads devour all low priority threads CPU Time .
2) The thread is permanently blocked in a state waiting to enter the synchronization block , Because other threads can always be ahead of it
Access the synchronization block continuously .
3) The thread is waiting for an object that itself is also permanently waiting for completion ( For example, the wait Fang
Law ), Because other threads are always awakened continuously .

  1. The necessary conditions for deadlock :

1) mutual exclusion : the Mutual exclusion means that a process monopolizes resources at a certain time .
Request and hold conditions : When a process is blocked by a request for resources , Keep the acquired resources .
3) Conditions of non deprivation : The process has acquired resources , Before the end of use , Can't be forcibly deprived .
4) Loop wait condition : A circular waiting resource relationship is formed between several processes .

  1. How to ensure N Threads can access N Resources do not cause deadlock at the same time

When using multithreading , A very simple way to avoid deadlock is : Specifies the order in which locks are acquired , And forces the thread to acquire locks in the specified order . therefore , If all threads lock and release locks in the same order , There will be no deadlock .

The context of multithreading

Multithreading will use the CPU, The number of threads is greater than the number of CPU In quantity , In order to let each thread have the opportunity to execute , It needs to rotate CPU. Different thread switching CPU The switching data is context switching .

12. Stack in memory (stack)、 Pile up (heap) Method area (method area) Usage of
  • Pile up : Methods store objects ( adopt new Keywords and constructors create objects )
  • Stack : Store methods and their local variables
  • Method area :( It's also called a shared area ) Store code fragment 、 Static attribute 、 Constant pool ( For example, the value of a string is stored in a constant pool )

Usually we define a Variables of basic data type , A reference to an object , Function calls are saved on site using JVM Stack space in ; and adopt new Objects created by keywords and constructors are placed in heap space , The heap is the main area managed by the garbage collector , Because the current garbage collector adopts the generational collection algorithm , So heap space can also be subdivided into Cenozoic and Paleozoic , More specifically, it can be divided into Eden、Survivor( It can also be divided into From Survivor and To Survivor)、Tenured; The method area and heap are
Is an area of memory Shared by each thread , Used for storage has been JVM Class information loaded 、 Constant 、 Static change
The amount 、JIT Compiler compiled code and other data ; The literal quantity in a program (literal) As in direct writing 100、”
hello” And constants are placed in the constant pool , Constant pools are part of the method area . Stack space to operate
Fastest, but the stack is small , Usually a large number of objects are placed in the heap space , Both stack and heap sizes can be passed through JVM
To adjust , Stack space used up will cause StackOverflowError, And heaps and constants
Lack of pool space can cause OutOfMemoryError
String str = new String("HelloWorld");, In this code , Variable str Put it on the stack , use new The created string object is put on the heap ,”HelloWorld” This literal quantity (String) Is placed in the method area .

13. switch Parameter type

JDK1.5 before ,switch() The parameters of the , Can only be byte、short、char、int.
from JDK1.5 Start , Java Introduced in Enumeration type and byte short char int The wrapper class .
from JDK 1.7 Start , Parameters can also be strings ( String) type , But long integers ( long) Not in all current versions .
Now switch Support byte、short、char、int、String、 enumeration

JDK1.5, Support for the four wrapper classes is due to java The compiler manually unpacks at the bottom , The support for enumeration classes is that enumeration classes have a ordinal Method , This method is actually a int Type value .
jdk1.7 Start supporting String type , But actually String There is a type of hashCode Algorithm , The result is also int type . and byte short char Types can be transformed up to... Without losing precision int type , So in general , It can be said that switch China only supports int.

14. Two objects have the same value (x.equals(y) == true), But it can be different hash code, Is that right ?【***】

incorrect , If two objects x and y Satisfy x.equals(y) == true, Their hash code (hash code)
Should be the same .
Java about eqauls Methods and hashCode The method is prescribed as follows :

1) If two objects are the same (equals Method returns true), So their hashCode The values must be the same ;
2) If I have two objects hashCode identical , They're not necessarily the same . Of course , You don't have to do it as required , however ( rewrite hashCode) If you violate the above principles, you will find that when using containers , The same objects can appear in Set Collection , At the same time, the efficiency of adding new elements will be greatly reduced ( For systems using hash storage , If hash code conflicts frequently, access performance will drop dramatically ).

About equals Method , The following must be met

First equals Methods must satisfy
1) reflexivity ( x.equals(x) Must return true)
2) symmetry x.equals(y) return true when , y.equals(x) You have to go back true
3) Transitivity (x.equals(y) and y.equals(z) All back to true when , x.equals(z) You have to go back true
4) Uniformity ( When x and y When the referenced object information is not modified , Multiple calls x.equals(y) You should get the same return value ) , And for Anything that is not null The value of the reference x,x.equals(null) Must return false.

Achieve high quality equals The knack of the method includes

1) Use == Operator check ” Parameter is a reference to this object ”;
2) Use instanceof Operator check ” Is the parameter the correct type ”;
3) For key attributes in a class , Check whether the property of the parameter passed in object matches it ;
4) rewrite equals After the method , Ask yourself if it satisfies reflexivity 、 symmetry 、 Transitivity 、 Uniformity ;
5) rewrite equals Always rewrite hashCode;
6) Don't put equals Method parameters Object Object is replaced with another type , Don't forget when rewriting @Override annotation .

15. String and StringBuilder、StringBuffer The difference between 【***】

Java The platform provides two types of strings : String and StringBuffer/StringBuilder, They can store and manipulate strings .
among String It's a read-only string , That means String The content of the referenced string cannot be changed .
and StringBuffer/StringBuilder Class String objects can be modified directly .StringBuilder yes JDK 1.5 Introduced in , It and StringBuffer The method is exactly the same , The difference lies in StringBuffer Because being synchronized modification , It's thread safe and StringBuilder It's not thread safe ( All aspects have not been synchronized modification )
because StringBuilder Has not been synchronized Synchronous modification , therefore StringBuilder

【 Interview questions 】 When to use + Operator to call string connection ratio StringBuffer/StringBuilder Object's append Method connection string has better performance ?

First of all, we should be clear about the following two points :
1)String Object's intern Method gets a reference to the corresponding version of the string object in the constant pool ( If there is a string in the constant pool and String Object's equals The result is true), If there is no corresponding string in the constant pool , The string will be added to the constant pool , Then return a reference to the string in the constant pool ;
2) A string of + The essence of operation is to create StringBuilder Object to carry out append operation , And then After splicing StringBuilder Object use toString Method String object .

16. heavy load (Overload) And rewrite (Override) The difference between . Can overloaded methods be distinguished by return type ?

Method overloading and rewriting are ways to implement polymorphism , The difference lies in Overloading implements compile time polymorphism , and Rewriting implements runtime polymorphism .
Overloading is compiler time polymorphism , According to the actual parameter list , At compile time, you can determine which of the overloaded methods to execute .
So called rewriting is runtime polymorphism , For example, when a parent class object refers to a child class instance , The calling method only knows at runtime which method was executed .
heavy load It happened in In a class , If a method with the same name has a different parameter list ( Different parameter types 、 The number of parameters is different or both are different ) It is regarded as a heavy load ;( Overload has no special requirements for return type , Consider only the parameter list )
Overriding occurs between a subclass and a superclass ( Need to inherit ), Rewriting requirements A subclass overridden method has the same return type as a superclass overridden method , Better access than parent class overridden method , No more exceptions can be declared than the overridden method of the parent class ( Richter substitution principle ).

17. JVM What is it? ? Why? Java Be called “ Platform independent programming language ”?JVM load class The principle and mechanism of documents 【***】

Java A virtual machine is a It can be executed Java Virtual machine process of bytecode .Java Source files are compiled to be able to be Java Bytecode file executed by virtual machine .

Java Designed to allow applications to run on any platform , It doesn't need to be rewritten or recompiled by the programmer for each platform .Java Virtual machines make this possible , Because it knows the instruction length and other characteristics of the underlying hardware platform .

Java Code in JVM The execution process in
 Insert picture description here
JVM Class loading schematic diagram of
 Insert picture description here
JVM The loading of classes in is done by the class loader ( ClassLoader) And its subclasses , Java The classloader in is an important Java Runtime system components , It is responsible for finding and loading classes in class files at run time .
because Java Cross platform , Compiled Java The source program is not an executable program , It's one or more classes class file . When Java When a program needs to use a class ,JVM Will ensure that this class has been loaded 、 Connect ( verification 、 Preparation and analysis ) And initialize . Class loading refers to the loading of .class The data in the file is read into memory , Usually create a byte array to read in .class file , Then generate the corresponding Class object . After loading ,Class The object is not complete yet , So the class at this time is not available . When the class is loaded, it enters the connection phase , This phase includes validation 、 Get ready ( Allocate memory for static variables and set default initial values ) And analysis ( Replace symbol references with direct references ) Three steps . Last JVM Initialize the class , Include :
1) If a class has a direct parent and the class has not been initialized , Then initialize the parent class first ;
2) If there is an initialization statement in the class , Execute these initialization statements in turn .

Class loading is done by the class loader
Class loaders include : Root loader (BootStrap)、 Extended loader (Extension)、 System loader ( System) And user-defined class loaders (java.lang.ClassLoader Subclasses of ) .
from Java 2( JDK 1.2) Start , The parent delegation mechanism is adopted in the class loading process (PDM).PDM Better guarantee Java Security of the platform , In this mechanism , JVM Self contained Bootstrap It's a loader , Other loaders have only one parent loader . Class loading first requests the parent class loader to load , When the parent loader is unable to do anything, it will be loaded by its child loader .JVM No direction Java Program provider pair Bootstrap References to .

  • Bootstrap: Generally implemented by local code , Responsible for loading JVM Basic core class library (rt.jar);
  • Extension: from java.ext.dirs Load the class library in the directory specified by the system property , Its parent loader is Bootstrap;
  • System: Also called application class loader , The parent class is Extension. It is the most widely used classloader . It takes the environment variable classpath Or system properties java.class.path The specified directory records the class , Is the default parent loader for user-defined loaders .
18. Java Is there a memory leak in ?

Theoretically ,Java Because of the garbage collection mechanism ( GC) No memory leaks ( This is also Java An important reason for being widely used in server-side programming );
However In actual development , May exist Useless but accessible objects , These objects cannot be GC Recycling , Therefore, memory leakage may occur .
for example :Hibernate Of Session( First level cache ) Objects in are persistent , The garbage collector doesn't recycle these objects , However, there may be useless garbage objects in these objects , If you don't close it in time (close) Or empty ( flush) First level cache may cause memory leak .

// A stack is implemented ( First in, then out (FILO)) Structure code
import java.util.Arrays;
import java.util.EmptyStackException;
public class MyStack<T> {
private T[] elements;
private int size = 0;
private static final int INIT_CAPACITY = 16;
public MyStack() {
elements = (T[]) new Object[INIT_CAPACITY];
public void push(T elem) {
elements[size++] = elem;
public T pop() {
if(size == 0)
throw new EmptyStackException();
return elements[--size];
private void ensureCapacity() {
if(elements.length == size) {
elements = Arrays.copyOf(elements, 2 * size + 1);

The above code is to achieve a stack after the first out (FILO) structure , however Among them pop There are methods
Memory leaks

When we use pop Method to pop up objects in the stack , The object will not be garbage collected , Even if the program using the stack no longer references these objects , Because expired references to these objects are maintained inside the stack (obsolete reference).
In languages that support garbage collection , Memory leaks are hidden , such Memory leaks are actually unconscious object retention . If an object reference is retained unconsciously , The garbage collector will not process this object , Other objects referenced by this object will not be processed , Even if there are only a few such objects , It may also result in many objects being excluded from garbage collection , This has a significant impact on Performance , In extreme cases, it can trigger Disk Paging( Data exchange between physical memory and virtual memory of hard disk ), Even cause OutOfMemoryError.

19. Abstract method (abstract) Whether it can be static (static)、 Local method (native) And synchronization (synchronized) modification .

The answer is neither .
1) Abstract methods need subclass rewriting , Static methods cannot be overridden , So they are contradictory .
2) Local methods are created by local code ( Such as C Code ) Method of implementation , Abstract methods are not implemented , It's also contradictory .
3)synchronized Related to the implementation details of the method , Abstract methods do not involve implementation details , So it's also contradictory .

20. Differences between static variables and instance variables

Static variables are defined by static Modifier variable , Also known as class variables , It belongs to the category. ( Life and death with the same class ), Any object that does not belong to a class , A class no matter how many objects are created , Static variables have only one copy in memory ; Static variables allow multiple objects to share memory .
Instance variables must be dependent on an instance , You need to create an object before you can access it through it .
( stay Java In development , There are usually a large number of static members in context classes and tool classes .)

21. Implement object cloning 2 Methods 【***】

Objects are reference data types , The assignment of an object is simply to assign a reference of an object to another object , their Heap space It's the same .
Cloning is the need to have exactly the same object , And there's no interaction between the two , The clone object and the original object are two completely opposite objects .(java.lang.Object Class clone() Method , Object cloning is the replication of objects , That is to copy an object completely .)

1) Realization Cloneable Interface and override Object Class clone() Method ;( The clone of shallow clone object is shallow clone by default , In other words, objects contained in objects are not cloned ),【 adopt clone() To achieve deep cloning : Let the class contained in the cloned object also implement clone function ( Realization cloneable Interface , heavy load clone() Method )】
2) Realization Serializable Interface , Cloning through serialization and deserialization of objects , True deep cloning possible

Based on serialization and deserialization (Serializable) Cloning is more than deep cloning , More importantly, by generics , You can check whether the object to be cloned supports serialization , This test is The compiler does , Not throwing an exception at run time , This scheme is obviously better than using Object Class clone Method clone object . It's always better to expose problems at compile time than to leave them at run time .

22. Java How to realize serialization in Serializable, What's the point ?

Serializable Serialization is a way to The mechanism for handling object flows , The so-called object flow is to flow the content of the object . Can read and write to the object after convection , You can also transfer the streamed objects between networks .
Serialization is for Solve the problems that may be caused by object stream read and write operations ( If not serialized, the data may be out of order ) .
To implement serialization , You need to make a class Realization Serializable Interface , The interface is an identifying interface , Indicates that the class object is serializable , Then an output stream is used to construct an object output stream and pass the writeObject(Object) Method to write out the implementation object ( Save its status );
If you need to deserialize, you can use an input stream to build an object input stream , And then through readObject Method to read objects from the stream . Serialization can achieve object persistence , Can also be used for deep cloning of objects ( Above mentioned ).

23. GC Garbage collector , Why do you need it .【***】

java Zhongyou JVM The garbage collection Manager for (GC) Is responsible for Reclaiming unused heap memory and stack memory .GC The function can automatically monitor whether the object is beyond the scope to achieve the purpose of automatically reclaiming memory .
JVM The recycling of garbage uses Dynamic storage management technology , It can Check your memory usage , Automatically release objects that are no longer referenced by the program , According to the specific garbage collection algorithm to achieve the automatic recovery function of memory resources .
JVM Garbage collection Manager handles and releases useless objects , You can also clear the memory record fragments ( Because objects are created and garbage collected, the space occupied by their objects is constantly released , So the memory will be fragmented ). Defragmentation moves the occupied heap memory to one end of the heap ,JVM Allocate the defragmented memory to new objects .
JVM The garbage collector has a potential drawback : Increased system overhead , Affect the performance of the program . because JVM The useful objects in the running program must be tracked , To finally release the useless object , This process takes processor time .
If an object is no longer referenced by any stack memory , The object becomes a garbage object . The collection time of garbage objects by the garbage collector is uncertain , It can also be used directly System.gc() Method Runtime.getRuntime().gc() Recycling objects , But this kind of mandatory garbage collection program has a negative impact on system performance .(JVM It can mask the garbage collection calls displayed , Is to show the calling method ,JVM Of GC Will automatically manage ) Although you can call System.gc() perhaps Runtime.gc(), But there's no guarantee GC Implementation .

Garbage collection can Effectively prevent memory leak , Effective use of available memory . The garbage collector usually runs as a separate low priority thread , Unpredictable cleaning and recycling of dead or unused objects in the memory heap , Programmers can't call garbage back in real time
The collector garbage collects an object or all objects . stay Java Early stage of birth , Recycling is Java
One of the biggest highlights , Because programming on the server side needs to effectively prevent memory leakage , But time passed
Jingqian , Now Java The garbage collection mechanism of has been criticized . Mobile Smart end users usually
Think iOS System ratio Android The system has a better user experience , One of the deep reasons is that
On Android The unpredictability of garbage collection in the system .

Add : There are many kinds of garbage collection mechanisms , Include : Generational replication garbage collection 、 Mark garbage collection 、 The incremental
Garbage collection, etc . The standard Java Processes have stacks and heaps . Stack holds primitive local variables , Pile up
Save the object to be created .Java The platform's basic algorithm for heap memory recycling and reuse is called tagging and
eliminate , however Java It has been improved , use “ Generational garbage collection ”. This method will follow Java
The life cycle of an object divides heap memory into different regions , In the garbage collection process , Objects may be
Move to a different area :

24. String And basic data types

1) Convert a string to a base data type
Call the method in the wrapper class corresponding to the basic data type parseXXX(String) or valueOf(String) You can return to the corresponding basic type ;
2) Convert basic data type to string
One way is to match the basic data type with an empty string "" adopt + Join to get the corresponding string ;
Another way is to call String Class valueOf() Method returns the corresponding string .String.valueOf()

25. Java and JavaScript difference

Java and JavaScript Introduce

JavaScript And Java It's two different products developed by two companies .Java Is the original Sun Microsystems company-launched Object oriented programming language , Especially suitable for Internet application development ; and JavaScript yes Netscape Products of the company , In order to extend the Netscape Browser function and development of One can be embedded in Web An object-based and event driven interpretive language running on a page .
JavaScript The predecessor was LiveScript; and Java The predecessor was Oak Language .

Java and JavaScript The difference between

1)Java It's object-oriented and JavaScript It's object-based .
Java Is a real object-oriented language , Even developing simple programs , Object must be designed ;JavaScript It's a scripting language , It can be used to make network independent , Complex software interacting with users . It's an object-based (Object-Based) And event driven (Event-Driven) Programming language , Therefore, it provides rich internal objects for designers to use .
2)Java It's compiling and running , and JavaScript It's the interpretation of execution .
Java Before execution , Must be compiled .JavaScript Is an interpretive programming language , Its source code does not need to be compiled , Interpreted by browser .( Almost all current browsers use JIT( Just in time compilation ) Technology to improve JavaScript Operating efficiency
3)Java Variables must be declared before using ,JavaScript It's a weakly typed language , Use it directly .
Java Use strong type variable check , All variables must be declared before compiling ;JavaScript Medium variable is weakly typed , You can even use variables without declaring them ,JavaScript At run time, the interpreter infers its data type .
4)Java It's a static language ,JavaScript It's dynamic language .

26. try{} There's one in it return sentence ,finally Whether to carry out , Execution location .

try{} There's one in it return Statement returns , So it's right here try After finally{} The code in will also be executed , yes Before the method returns the call (return Pre execution )
If there is finally Code block ,try Medium return Statement does not immediately return the caller , Instead, record the return value to be finally After the code block is executed, its value is returned to the caller ( perform return).
stay finally It is not good to change the return value in , If in finally Return value modified in , It will return the modified value . stay finally Return or modify the return value will cause a lot of trouble to the program ,C# In order to prevent programmers from doing such dirty things, compile errors are directly used ,Java You can also raise the syntax check level of the compiler to generate warnings or errors (idea、eclipse You can set it yourself )

27. Runtime exceptions and checked exceptions

An exception indicates an abnormal state that may occur during program operation .
Runtime exception : Represents an exception that may be encountered in the normal operation of a virtual machine , Is a common run error , As long as the program is well designed, it usually doesn't happen .( At run time, it throws )
Abnormal under examination Related to the context in which the program runs , Even if the program design is correct , May still be caused by problems in use .Java The compiler requires methods to declare that they throw possible checked exceptions , But it is not necessary to declare that an uncaught runtime exception must be thrown .
Common runtime exceptions :

ArithmeticException( Arithmetical abnormality )
ClassCastException ( Class conversion exception )
IllegalArgumentException ( Illegal parameter exception )
IndexOutOfBoundsException ( Subscript out of range exception )
NullPointerException ( Null pointer exception )
SecurityException ( Security exception )

28. final、finally、finalize The difference between

final keyword

A basic data type is declared as final, It can only be assigned once ( initialization ), The compiler automatically checks the code , If modification is needed final The initialization , It will compile and report errors .final Declared reference data type , The current reference cannot be changed , But you can change the value of the memory space that the reference points to .final In general, and static Use it as a constant .
final Three uses of keywords :
1) decorator : Indicates that the class cannot be inherited ;
2) Modification methods : Representation cannot be overridden ;
3) Modifying variables : Indicates that the value cannot be modified after the variable can only be assigned once ( Constant )(final Decorated member variables must be initialized at declaration time or in the constructor , Otherwise, a compilation error will be reported , and final Modified variables are usually constants , Constant names are all uppercase )
If a class is declared as final, This means that it can no longer derive new subclasses , That is, it cannot be inherited , So it and abstract Antonyms . Declare variable as final, It can guarantee that they will not be changed in use , Be declared final Must be declared with an initial value , But in the later reference, it can only read and cannot be modified . Be declared final The same can only be used , Cannot be overridden in a subclass .

final advantage
1)final Keywords can improve performance ,JVM and Java Application will cache final Variable .
2)final Variables can be shared in a secure multithreaded environment , Without any additional synchronization overhead .


Usually placed in try…catch… Subsequent constructs of always execute code blocks , This means that whether the program is running normally or not , The code here is just JVM Can be executed without closing , Can be The code for releasing external resources is written in finally In block ( Close database connection 、 Release resources ).


Object Methods defined in class ,Java Allowed in finalize() Method do the necessary cleanup before the garbage collector clears the object from memory . This method is made by The garbage collector calls Of , By rewriting finalize() Methods can organize system resources or perform other cleanup tasks .

29. List、Map、Set When three interface access elements , What are the characteristics of each ?

List In a specific way Indexes To access elements , Can have repeating elements .
Set Cannot store duplicate elements ( Object oriented equals()* Method to distinguish whether the element is repeated ).
**Map** preservation *
Key value pair ( key-value) mapping
, The mapping relationship can be one to one or many to one .(Map Does not support one to many , But you can use Map<Integer, List> This format is used to achieve a one to many system , Many to many is similar to )

Set and Map All containers have Two implementations based on Hash storage and sort tree edition , Based on Hash storage version theory, the access time complexity is O(1), The implementation based on the sort tree version will insert or delete elements according to their keys ( key) In order to achieve the effect of sorting and de duplication .

30. ArrayList、Vector、LinkedList Storage performance and characteristics of 【***】

ArrayList and Vector All are Use array to store data , The number of elements in this array is greater than the data actually stored in order to increase and insert elements , they Allows you to index elements directly by ordinal number , But inserting elements involves memory operations such as array element movement , So index query data fast and insert data slowly ,
Vector Because of the addition of synchronized modification , therefore Vector Is a thread safe container , But in terms of performance ArrayList Bad , So it's already Java Legacy containers in .
LinkedList Use Double linked list Implement storage ( Associate scattered memory units in memory with additional references , Form a linear structure that can be indexed by ordinal number , This kind of chain storage is compared with the continuous storage of arrays , Higher memory utilization ) , Index data by sequence number needs to be traversed forward or backward , But when inserting data, you only need to record the front and back items of this item , So the insertion speed is faster .
Vector Belongs to legacy container (Java Containers available in previous releases , besides ,Hashtable、Dictionary、BitSet、Stack、Properties It's all legacy containers ), Not recommended anymore , But because of ArrayList and LinkedListed It's all non thread safe , If multiple threads operate on the same container , You can use tools Collections Medium synchronizedList Method to convert it into a thread safe container before using ( This is the application of decoration mode , Passing an existing object into the constructor of another class to create a new object to enhance the implementation ).

31. Collection and Collections The difference between ,Collections In a tool class sort() Method how to compare elements ,TreeMap and TreeSet How to compare elements in sorting

Collection It's an interface , It is Set、List The parent interface of the container .
Collections Is a tool class , Provides a series of static methods to assist container operations , These methods include searching for containers 、 Sort 、 Thread safety, etc .

Collections The utility class sort Methods have two forms of overloading , The first request is to pass in
Compare the objects stored in the container to be sorted Comparable Interface to implement element comparison ; The second optional requirement is that the elements in the container must be comparable , But a second parameter is required , Parameter is Comparator Subtype of interface ( Need to rewrite compare Method implementation element comparison ), Equivalent to a temporarily defined collation , In fact, it is the algorithm of comparing element size through the interface , It is also an application of callback mode ( Java Support for functional programming in ).

TreeSet requirement The class to which the stored object belongs must implement Comparable Interface , This interface provides Comparing elements of compareTo() Method , When the element is inserted, the method is called back to compare the size of the element .
TreeMap It is required that the stored key value pair must be mapped to Realization Comparable Interface To sort the elements by key .

32. XML There are several forms of document definition ? What is the essential difference between them ? analysis XML How do documents work ?

1)XML Document definition is divided into DTD and Schema Two forms , Both are right XML Grammatical constraints .
2)DTD and Schema The essential difference between the two forms is that Schema It's also a XML file , Can be XML Parser parsing , And it can XML Hosted data definition type , Restraint ability DTD More powerful .
3) Yes XML The analysis of DOM( Document object model ,Document Object Model)、SAX( Simple API forXML) and StAX(JDK1.6 New analysis introduced in XML The way ,Streaming API for XML).

among DOM When dealing with large files, their performance is greatly reduced , This problem is caused by DOM Tree structure takes up more memory , and DOM Parsing mode must load the entire document into memory before parsing the file , Suitable for XML Random access to ( Typical use Space for time The strategy of );
SAX It's event driven XML Analytical way , it Sequential read XML file , You don't need to load the entire file all at once . When you encounter something like the beginning of a file , End of document , Or at the beginning and end of the label , It triggers an event , The user handles it through the event callback code XML file , Suitable for XML Sequential access to ; seeing the name of a thing one thinks of its function ,
StAX Focus on flow On , actually StAX The essential difference from other analytical methods is that Applications can put XML Handle as an event flow .SAX That's how it's done , But the difference is StAX Allow application code to pull these events out one by one , Instead of providing a handler to receive events from the parser at its convenience .

33. XML Main role of

XML There are two main functions of : Data exchange and information configuration .
When doing data exchange ,XML Assemble data with labels , Then compressed, packed, encrypted and transmitted to the receiver over the network , Receive decryption and decompress, and then XML Restore relevant information in the file for processing ,XML Used to be the de facto standard for data exchange between heterogeneous systems , But this feature has almost been JSON( JavaScript Object Notation) Instead, . Of course , At present, many software still use XML To store configuration information , We're in a lot of projects
The hard code used as configuration information is usually written in XML In file ,Java Many of our frameworks do the same , And these frameworks have been chosen dom4j As a handle XML Tools for ,( because Sun Official of the company API It's really not easy to use .)

34. JDBC To operate a database (MySQL)
//1. load JDBC The driver ( load MySQL Drive class )
//2. Provide JDBC Connected URL To create a connection
//databaseName Database name ,useUnicode=true: Said the use of Unicode Character set ,characterEncoding=UF-8 Character encoding utf-8, udrtnsmr and password yes mysql Connect user name and password
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/databaseName?useUnicode=true&characterEncoding=UF-8;",username,password);
// Can also be mysql The driver writes to DriverManager.getConnection() in
//3. PreparedStatement precompile sql
String sql = "select * from dept where id = ? and name = ?";
PreparedStatement ps = con.prepareStatement(sql);
ps.setInt(1, 10);
ps.setInt(2, " researcher ");
//4. perform SQL sentence
ResultSet rs = ps.executeQuery();
//5. Processing results
while( {
//6. stay finally Release resources inside ( External resources should be closed in reverse order to open )
if(rs !=null){
if(ps != null){
if(con != null) {
35. Statement and PreparedStatement Which is better ?

PreparedStatement Better performance
1)PreparedStatement Interface represents precompile The sentence of , Its main advantage is that it can Reduce SQL Compile errors and add SQL The security of ( Reduce SQL Possibility of injection attack )
2) PreparedStatement Medium SQL Statements can have parameters , Avoid string concatenation SQL Trouble and insecurity of statements ;
3) When batch processing SQL Or frequent execution of the same query ,PreparedStatement Obvious performance advantages , Because the database can compile the optimized SQL Statement cached , The next time a statement of the same structure is executed, it will be very fast ( No need to recompile and generate the execution plan ).

36. JDBC Can we handle it? Blob and Clob

Blob Binary large object (Binary Large Object)
Clob Large character object (Character Large Objec)
Blob Designed to store large binary data , and Clob Designed to store large text data .JDBC Of PreparedStatement and
ResultSet All provide corresponding methods to support Blob and Clob operation ( Flow operation ).

37. Database programming , The advantages of connection pooling

because Both creating and releasing connections have a lot of overhead ( Especially when the database server is not local , Every time a connection is established TCP Three handshakes of , It takes four waves to release the link , It costs a lot ), In order to improve the performance of system accessing database , Several connections can be created in advance and placed in the connection pool , Get directly from the connection pool when needed , Return connection pool at end of use without closing connection , thus Avoid the overhead of frequently creating and releasing connections , This is a typical use of Space for time The strategy of ( Wasted space to store connections , But it saves time to create and release connections ).
Pool technology stay Java Common in development , Creating a thread pool when using threads works the same way . be based on Java The main open source database connection pools are : C3P0、Proxool、DBCP、BoneCP、Druid etc. .
In fact, a key to optimizing the performance of large websites is to use cache ,, But slowly
Storage and connection pooling are very similar , It's also a strategy of using space for time . Hotspot data can be put into cache , When users query the data, they can get it directly from the cache , Avoid frequent access to the database resulting in a lot of overhead ( Now mainly used Redis Implementing caching )

38. Java layered ,Dao What is the pattern ?

DAO( Data Access Object) It's a An object that provides an abstract interface to a database or other persistence mechanism , Various data access operations are provided without exposing the implementation details of the underlying persistence scheme . In actual development , All access operations to the data source should be abstracted and encapsulated in a common API in .
In programming language , It's about building an interface , All transaction methods that will be used in this application are defined in the interface . In this application , Use this interface when you need to interact with data sources , And write a separate class to implement the interface , Logically, this class corresponds to a specific data store .DAO The pattern actually contains two patterns , One is Data Accessor( Data accessor ), Two is Data Object( Data objects ), The former is to solve the problem of how to access data , The latter is about how to encapsulate data with objects .

39. The nature of transactions ACID, Transaction isolation level , Concurrency of transactions 【****】
  1. The transaction is ACID Four features :

1) Atomicity (Atomicity): Business is a Indivisible work unit , Either the operations in the transaction occur , Or none at all
2) Uniformity (Consistency): The data integrity must be consistent after the transaction completes
3) Isolation, (Isolation): When multiple users access the database concurrently , One user's transaction cannot be interfered with by another user's transaction , Data between multiple concurrent transactions is isolated from each other
4) persistence (Durability): Once a transaction is committed , The changes it makes to the data in the database should be permanent , Even if the database fails, it should not have any impact

If the , There's something wrong with anything / error , Then the transaction will be rolled back , After the rollback, the state of the data will be exactly the same as before the transaction .

  1. The isolation level of the transaction :

Database provides automatic locking mechanism for users , As long as the user specifies the transaction isolation level of the session , The database will pass the analysis SQL Statement and then apply the appropriate lock to the resource accessed by the transaction .
Isolation level refers to the isolation level between several concurrent transactions .TransactionDefinition There are five constants defined in the interface that represent the isolation level ( Used to solve concurrency problems ) In general, the middle two are OK .

TransactionDefinition Interface transaction isolation level describe
READ_UNCOMMITTED This isolation level indicates that one transaction can read the data modified by another transaction but not yet committed . This level Can't prevent dirty reading , No repeated reading or phantom reading , So this isolation level is rarely used .
READ_COMMITTED System The default value is , This isolation level means that one transaction can only read the data that another transaction has committed . It can prevent dirty reading , Is the recommended value in most cases .
REPEATABLE_READ This isolation level indicates that a transaction can execute a query repeatedly in the whole process , And the records returned each time are the same . This level It can prevent dirty reading and non repeatable reading .
SERIALIZABLE All transactions are executed one by one , There is no interference between transactions . This level prevents dirty reads 、 Unrepeatable reading and phantom reading . But it will Seriously affect the performance of the program . This level is not usually used .
Isolation level (√: Allow to appear ×: Not allowed ) Dirty reading It can't be read repeatedly Fantasy reading The first type of lost updates The second kind of lost updates

Transaction isolation level and data access concurrency are opposite , The higher the transaction isolation level, the worse the concurrency . Therefore, the appropriate transaction isolation level should be determined according to the specific application , There is no universal principle in this place .

  1. Concurrency of transactions

The first thing to know is , Transactions are only required if there is concurrent data access ( Submit / Rolling back ends the transaction ), When multiple transactions access the same data , May exist 5 Class concurrency , Include 3 Class data reading problem ( Dirty reading 、 It can't be repeated and unreal
Reading and 2 Class data update problem ( The first 1 Class lost updates and 2 Class missing update )
3 Class data reading problem

1) Dirty reading (Dirty Read): One transaction has read another transaction's uncommitted data . ( such as A Transaction read B Data not yet committed by transaction and operate on this basis , and B Transaction execution rollback , that A The data read is dirty data .)( Very serious behavior , Must handle , Or it could have a big impact , For example, transfer business )
2) It can't be read repeatedly (Unrepeatable Read): Data read multiple times in a transaction is inconsistent , One transaction reads the modified data of another transaction .( It can't be read repeatedly , Make sure the data is modified , There won't be twice the same data )
3) Fantasy reading ( Virtual reading Phantom Read): One transaction read another transaction insert Data submitted .( For example, affairs. A Re execute a query , Returns a series of rows that meet the query criteria , Transaction inserted B Submitted rows )( It can't be in MySQL in , It will only appear in Oracle in )

Two kinds of missing update problems

1) The first type of lost updates :
Business A When revoked , Put the submitted transaction B The updated data of ( such as Withdrawals A Open transaction query balance 1000 element , Transfer transaction B Open transaction transfer 100 to A,A Take out 100, After committing the transaction , Check the balance again 1000 element )
2) Business A Overlay transaction Submitted data , Cause affairs B Operation lost ( such as : Withdrawals A And transfers B Start business one after another , Check the balance successively 1000 element , Withdrawals A Take out 100, The balance becomes 900, Commit transaction , But at this time the transfer business B Deposit in 100, Change the balance to 1100 element , Commit transaction , And then check the account balance, which is 1100, Withdrawals A Lost operation for )

JDBC How to do transactions :

Connection Provides methods for transaction processing , By calling setAutoCommit(false) You can set up a manual commit transaction . Use when the transaction is completed commit() Explicitly commit transactions ; If an exception occurs during the transaction, the rollback() Perform transaction rollback . besides , from JDBC 3.0 It also introduces Savepoint( Save it ) The concept of , Allows the savepoint to be set by code and the transaction to be rolled back to the specified savepoint .

40. What is regular expression ,Java How to support regular expressions in .

When writing programs that handle strings , There is often a need to find strings that meet certain complex rules . Regular expressions are tools for describing these rules . let me put it another way , Regular expressions are Code that records text rules . Regular expressions are just doing String matching and processing is the most powerful tool , Most languages provide support for regular expressions .
Java Medium String Class provides methods to support regular expression operations , Include : matches()、replaceAll()、replaceFirst()、split() Besides ,Java Can be used in the Pattern class Represents a regular expression object , It provides a wealth of API Perform various regular expression operations .

41. obtain Class Three methods of object , Methods of creating objects by reflection

obtain class Three methods of object :

1) Every class adopt class attribute obtain .【 Class name .class
2) Every object adopt getClass() Method obtain .【 object .getClass()
3) adopt Class.forName(“ The full name of the class ”) obtain , Need to catch exception .【Class.forName(" The full name of the class ")

The first way , Class name .class No classes will be loaded into memory , The third kind of Class.forName() Will load the class into memory , object .getClass()( Created object ) Will be loaded into memory

There are two ways to create objects by reflection :

1) By class object (class) call 1newInstance()1 Method , For example, create String object :
2) By class object (class) Of getConstructor()getDeclaredConstructor() Method Get the constructor (Constructor) Object and Call its newInstance() Method Create objects , for example :

42. 23 A classic design pattern
type Design patterns
Creation type Factory method model (FactoryMethod)、 Abstract factory pattern (AbstractFactory)、 Builder pattern (Builder)、 Archetypal model (Prototype)、 The singleton pattern (Singleton)
Structural type Adapter pattern (Adapter)、 Bridging mode (Bridge)、 Portfolio model (Composite)、 Decorator mode (Decorator)、 Facade mode (Facade)、 The flyweight pattern (Flyweight)、 The proxy pattern (Proxy)
Behavior type Interpreter mode (Interpreter)、 Template method pattern (TemplateMethod)、 The chain of responsibility model (ChainofResponsibility)、 Command mode (Command)、 Iterator pattern (Iterator)、 Mediator model (Mediator)、 Memo mode (Memento)、 Observer mode (Observer)、 The state pattern (State)、 The strategy pattern (Strategy)、 Visitor mode (Visitor)

The singleton pattern : A class has only one instance , And this class can create a pattern of this instance by itself .( Slacker type 、 Hungry Han style writing )
Archetypal model : Use an instance that has been created as a prototype , Create a new object that is the same or similar to the prototype by copying the prototype object .
The strategy pattern : A series of algorithms are defined , And encapsulate each algorithm , Make them interchangeable , And the change of algorithm will not affect the customers who use the algorithm . The strategy pattern belongs to the object behavior pattern , It encapsulates the algorithm , Separate the responsibility of using the algorithm from the implementation of the algorithm , And delegate to different objects to manage these algorithms .
Factory mode : Define a factory interface for creating product objects , Postpone the actual creation of product objects to specific sub factory classes . Factory classes can generate different subclass instances according to conditions , These subclasses have a common abstract parent and implement the same methods , But these methods operate differently for different data ( Polymorphic method ). When you get an instance of a subclass , Developers can call methods in the base class without considering which subclass instances are returned .
The proxy pattern : Provide a proxy object for an object , And the proxy object controls the reference of the original object . In development , According to different purposes , The agency can be divided into : Remote agent 、 Virtual agent 、 Protection agency 、Cache agent 、 Firewall proxy 、 Synchronization agent 、 Intelligent reference agent .
Adapter pattern : Transform the interface of one class into another expected by the client , So that classes that cannot be used together due to interface mismatches can work together .
Template method pattern : Provide an abstract class , Implement part of logic in the form of concrete methods or constructors , Then declare some abstract methods to force the subclass to implement the remaining logic . Different subclasses can implement these abstract methods in different ways ( Polymorphic implementation ), So as to realize different business logic .
The state pattern : For objects in a state , Put the complicated “ Judgment logic ” Extract into different state objects , Allows a state object to change its behavior when its internal state changes .
Decorator mode : It refers to... Without changing the existing object structure , Add some responsibilities to the object dynamically ( That is to add its extra functions ) The pattern of , It's an object structured pattern .
You can see the rest from this :23 Detailed explanation of design patterns

43. Seven principles of object-oriented design
principle describe
Opening and closing principle (OCP) Software entities should be open to expansion , Turn off for changes
Richter's principle of substitution (LSP) This paper expounds some principles of inheritance ( When to use inheritance ), Richter's substitution is the basis of inheritance reuse , It reflects the relationship between base class and subclass , It is a supplement to the principle of opening and closing , It's a specification of the concrete steps to achieve abstraction . It's understandable : A subclass can extend the functionality of a parent class , But you cannot change the original functionality of the parent class , That is, when the subclass inherits the parent class , In addition to adding new methods to complete the new functions , Try not to override the methods of the parent class .
The principle of Dependence Inversion (DIP) The core idea is : Interface oriented programming , Don't program for implementation .( The abstraction layer is relatively stable , So architecture based on abstraction is better than detail ( Implementation class ) The architecture built for the foundation is much more stable )
Principle of single responsibility (SRP) Put forward The object should not take on too much responsibility . Single responsibility also applies to methods . A method should do one thing as well as possible . If a method deals with too many things , It's going to get very coarse , Not conducive to reuse .
Interface isolation principle (ISP) Programmers are required to try their best to split the bloated interface into smaller and more specific interfaces , Let the interface contain only methods of interest to the customer . The interface should be small and specialized , Never be big and complete .
Dimitar's law (LoD) Also called the principle of least knowledge (LKP), One object should have as little knowledge of other objects as possible . If two software entities do not need to communicate directly , Then there should be no direct mutual calls , The call can be forwarded through a third party . The goal is to reduce the coupling between classes , Improve the relative independence of modules .
Synthetic multiplexing principle (CRP) It's called combination / Principle of aggregation and reuse (CARP) When software is reused , Try to use association relationships such as composition or aggregation to achieve , Second, consider using inheritance relationship to achieve .

summary :
The principle of opening and closing is the general principle , It tells us to be open to expansion , Turn off for changes ;
The Richter replacement principle tells us not to destroy the inheritance system ;
Dependency inversion principle tells us to face interface programming ;
The single responsibility principle tells us that the implementation class should have a single responsibility ;
The principle of interface isolation tells us to simplify the design of interfaces ;
Dmitry 's law tells us to reduce coupling ;
The principle of composite reuse tells us to prioritize the use of composite or aggregate relationship reuse , Use less inheritance to reuse .

44. UML Concept , Commonly used UML chart

UML Unified Modeling Language ( Unified Modeling Language) Abbreviation , It is published in 1997 year , It integrates the existing object-oriented modeling language at that time 、 Methods and processes , It is a graphical language supporting modeling and software system development , Provide modeling and visualization support for all phases of software development . Use UML Can help communication , Auxiliary application design and document generation , It can also explain the structure and behavior of the system .
Commonly used UML chart
Use case diagram (use case diagram)、 Class diagram (class diagram)、 Sequence diagram (sequencediagram)、 Collaboration map (collaboration diagram)、 State diagram (statechart diagram)、 Activity diagrams (activity diagram)、 Component diagram (component diagram)、 Deployment diagram (deploymentdiagram)
Use case diagram : To capture requirements , Describe the function of the system , Through this diagram, we can quickly understand the functional modules and their relationships of the system
Class diagram : Describe classes and the relationship between classes , Through this diagram, you can quickly understand the system
Sequence diagram : Describe the interaction between objects and the execution order when performing specific tasks , Through this graph, we can understand the messages that the object can receive, that is, the services that the object can provide to the outside world .

45. HashMap Realization principle

JDK1.8 in ,HashMap use Position bucket + Linked list + Red and black trees Realization , When the chain length exceeds the threshold value (8) when , Convert linked list to red black tree , This greatly reduces the search time .
HashCode yes jdk Use according to the address or string or number of the object hash The algorithm worked out int Type value .
HashMap Realization principle :

First of all, there is an array where each element is a linked list , When you add an element (key-value) when , Just calculate the elements first key Of hash value , To determine where to insert the array , But there may be the same hash The element of the value is already in the same position as the array , Then add it to the same hash After the element of value , They are in the same position in the array , But it's a chain , On the same list Hash The values are the same , So the array is a linked list . And when the list length is too long , The list is transformed into a red black tree , This greatly improves the efficiency of searching .
stay jdk8 in ,HashMap Handle “ Collision ” The data structure of red black tree is added , When there are fewer collision nodes , Using linked list storage , When larger (>8 individual ), Use red and black trees ( The feature is that the query time is O(logn)) Storage ( There is a threshold control , Greater than the threshold (8 individual ), Convert linked list storage to red black tree storage )

Red and black trees It's a kind of self Balanced binary search tree

A red black tree is a binary search tree with color attributes for each node , Color or red or black .
For any effective red black tree, there are the following requirements :
1) Nodes are red or black .
2) The root node is black .
3) Each leaf node is black .
4) The two children of each red node are black .( You cannot have two consecutive red nodes on all paths from each leaf to the root )
5 All paths from any node to each of its leaves contain the same number of black nodes .

46. Synchronous and asynchronous

If there are critical resources in the system ( The number of resources is less than the number of threads competing for resources ), For example, the data being written may be read by another thread later , Or the data being read may have been written by another thread , Then the data must be accessed synchronously ( Exclusive lock in database operation is the best example ).
When an application calls a method on an object that takes a long time to execute , And don't want the program to wait for the return of the method , You should use asynchronous programming , Asynchronous approaches are often more efficient in many cases .
in fact , Synchronization means blocking operation , Asynchronous is nonblocking .( Synchronization must wait for the result to return before it can continue , Asynchrony means that the browser sends a request , Whether the server returns results or not , You can carry on )

47. Servlet Life cycle of

Web Container loading Servlet And exemplify it ,Servlet Life cycle begins , The container runs its init() methods Servlet The initialization ; Called when the request arrives Servlet Of service Method ,service Method will call the corresponding request doGet or doPost Other methods ; When the server is shut down and the project is unloaded, the server will Servlet Example destruction , This will call Servlet Of destroy Method .

48. get and post Differences in requests

1)get Request to get resources from server , and post Is used to submit data to the server
2)get Set the data in the form according to the name=value In the form of , Add to action The point is URL Back , And both use “?” Connect , And the variables use “&” Connect ;post Put the data in the form HTML Head (header), Pass on to action Points to URL
3)get The data transmitted is subject to URL Length limit (1024 byte ); and post Can transfer a large amount of data , Upload files can only use post The way
4) Use get The time parameter will be displayed on the address bar , If these data are not sensitive data , Then you can use get; For sensitive data or applications post

49. HttpServlet The container responds Web Customer request process ?

1)Web The customer asked Servlet The container emits Http request ;
2)Servlet Container parsing Web Customer's Http request ;
3)Servlet The container creates a HttpRequest object , Encapsulate in this object Http Request information ;
4)Servlet The container creates a HttpResponse object ;
5)Servlet Container call HttpServlet Of service Method , This method will be based on request Of Method To judge whether it is to execute doGet still doPost, hold HttpRequest and HttpResponse Object as service The parameters of the method are passed to HttpServlet object ;
6)HttpServlet call HttpRequest About the method of , obtain HTTP Request information ;
7)HttpServlet call HttpResponse About the method of , Generating response data ;
8)Servlet Container handle HttpServlet The response result is passed to Web Customer

50. What is? Callable and Future?

Callable The interface is similar to Runnable, however Runnable No results returned , And cannot throw an exception that returns a result , and Callable More powerful , After being executed by thread , Can return value , This return value can be Future Get , in other words ,Future You can get the return value of asynchronous task execution . You can think of it as having a callback Runnable.
Future Interface represents asynchronous task , It's the future result of unfinished tasks . So Callable Used to produce results ,Future Used to get results .

JAVA Some topics and Java Some of the ways

  1. Math.round(11.5) How much ?Math.round(-11.5) How much ?

Math.round(11.5) The return value of 12, Math.round(-11.5) The return value of -11. Round up
The principle of input is to add 0.5 And then round it down

  1. short s1 = 1; s1 = s1 + 1; Anything wrong? ? short s1 = 1; s1 += 1; Anything wrong? ?

1)short s1 = 1; s1 = s1 + 1;
Compile error . because 1 yes int type , therefore s1+1 The result of the calculation is also int type , Cast type is required to assign to short type .
2)short s1 = 1; s1 += 1;
Compile correctly , because s1+= 1; amount to s1 = (short)(s1 + 1); There are implicit casts ( Self growth auto conversion , Unless you cross the line )

  1. Calculate with the most efficient method 2 multiply 8( Operator << and >> The concept of )

2 << 3( Move left 3 Bits are equal to times 2 Of 3 Power , Move right 3 Bits are equal to dividing by 2 Of 3 Power .

About operators << and >>
x >> n Namely First the x Convert to binary , Don't read the back n position
x << n Namely First the x Convert to binary , Add... To the binary data n individual 0

Case study :int x = 16;
x >> 1 Output x=8( First the x Convert to binary 10000, Don't read the last one 0, Output 1000, To 10 The base number is 8)
x << 1 Output x=32( First the x Convert to binary 10000,, Read one more bit at the end 0( Or depending on whether there has been a shift ), Output 100000, To 10 The base number is 32)

  1. Does the array have length() Method ?String Is there any length() Method ?

The array without length() Method , Only those who have length Properties of .String Yes length() Method . But in JavaScript in , To get the length of a string length Attribute ( It's very easy to talk to Java Mix up )

  1. When an object is passed as a parameter to a method , This method changes the properties of this object , And return the changed result , So is it value passing or reference passing ?

yes Value passed .Java Language method calls only support the value passing of parameters . When an object instance is passed to a method as a parameter , The value of the parameter is a reference to the object . The properties of an object can be called
Be changed in the process of using , But changes to object references do not affect the caller .C++ and C# Medium can
Change the value of an incoming parameter by passing a reference or an output parameter . stay C# You can write the following generation in
code , But in Java But you can't .

  1. String str = new String(“xyz”); Several string objects were created ?

Two objects , One is the static area ( Method area constant pool ) Of ”xyz“ character string , One is to use new Create objects on the heap str.

  1. Java There are several types of flows in , Their relationship

Java Mainly byte stream and character stream . Byte stream inherited from InputStream、OutputStream, Character stream inherited from Reader、Writer.
stay There are many other streams in the package , Mainly for improving performance and convenient use
About Java Of I/O There are two points to note :

1) Two symmetries ( Symmetry of input and output , Byte and character symmetry )
2) Two design patterns ( Adapter mode and decoration mode ).

  1. There are two ways to copy files by programming
public static void fileCopy(String source, String target) throws
IOException {
try (InputStream in = new FileInputStream(source)) {
try (OutputStream out = new FileOutputStream(target)) {
byte[] buffer = new byte[4096];
int bytesToRead;
while((bytesToRead = != -1) {
out.write(buffer, 0, bytesToRead);

NIO The way

public static void fileCopyNIO(String source, String target) throws
IOException {
try (FileInputStream in = new FileInputStream(source)) {
try (FileOutputStream out = new FileOutputStream(target)) {
FileChannel inChannel = in.getChannel();
FileChannel outChannel = out.getChannel();
ByteBuffer buffer = ByteBuffer.allocate(4096);
while( != -1) {
  1. Write a method , Enter a filename and a string , Count the number of times this string appears in this file .
// Count the number of times this string appears in this file
public static int countWordInFile(String filename, String word) {
int counter = 0; // Statistics
try (FileReader fr = new FileReader(filename)) {
try (BufferedReader br = new BufferedReader(fr)) {
String line = null;
while ((line = br.readLine()) != null) {
int index = -1;
while (line.length() >= word.length() && (index = line.indexOf(word)) >= 0) {
line = line.substring(index + word.length());
} catch (Exception ex) {
return counter;
  1. How to use Java Code lists all files in a directory ?
    1) Only the files in the current folder are listed
public static void main(String[] args) {
File f = new File("/Users/Downloads");
for(File temp : f.listFiles()) {
if(temp.isFile()) {

2) For the folder under the current folder, continue to expand to show all the files

private static void queryDirectory(File f, int level) {
if(f.isDirectory()) {
for(File temp : f.listFiles()) {
queryDirectory(temp, level + 1); // recursive
}else {
for(int i = 0; i < level - 1; i++) {
System.out.print("\t"); //\t Four spaces
System.out.println(f.getName()); // Output file name
public static void main(String[] args) {
queryDirectory(new File("/Users/Downloads"),0);

JDK1.7 Can be used later NIO.2 Of API Realization

public static void main(String[] args) throws IOException {
Path initPath = Paths.get("/Users/Downloads");
Files.walkFileTree(initPath, new SimpleFileVisitor<Path>() {
public FileVisitResult visitFile(Path file, BasicFileAttributesattrs) throws IOException {
return FileVisitResult.CONTINUE;
  1. TCP Programming through Socket Socket programming to achieve the server to send information to the client
    Server side :
import java.util.Scanner;
//socket,TCP Programming , Server program
public class Server {
public static void serverInfo(){
ServerSocket server = null;
Socket client = null;
PrintStream out = null;
try {
// On the server 8000 Port waiting for customer connection
server = new ServerSocket(8000);
System.out.println(" The server is waiting for the client to connect ......");
// Program blocking , Waiting for the client to connect
client = server.accept();
System.out.println(" Successful connection to client !!");
// Instantiate the print stream object , Used to send output information to the client
out = new PrintStream(client.getOutputStream());
System.out.println(" Please enter the information you want to send to the client :");
Scanner scan = new Scanner(; // Get input stream
// Ready to send information to the client
String info = " The server sends information to the client :" + scan.nextLine();
// Output information
scan.close(); // Close input stream
out.close(); // Turn off the output print stream
client.close(); // Close client
server.close(); // Turn off the server-side training
} catch (IOException e) {
public static void main(String[] args) {
serverInfo();// Open server

client :

//socket Programming , client , It should be consistent with the port number of the server
public class Client {
public static void clientInfo(){
// Statement socket object
Socket client = null;
try {
// Instantiation socket object , Specify the host name and port number of the connection
client = new Socket("localhost",8000);
System.out.println(" Client connection successful ");
// Declare cache character stream , To receive information
BufferedReader buf = new BufferedReader(new InputStreamReader(client.getInputStream()));
// Read information
String info = buf.readLine();
// Output read information
System.out.println(" The client receives the server ("+ client.getInetAddress() +") The message from the end :【" + info + "】");
} catch (IOException e) {
public static void main(String[] args) {

function :

1、 Open server Server

Server: The server is waiting for the client to connect …

2.、 Open client Client

Server:( Output content )
The server is waiting for the client to connect …
Successful connection to client !!
Please enter the information you want to send to the client :
Client:( Output content )
Client connection successful

3、Server Input content HelloWorld

client Client Received information :
The client receives the server (localhost/ The message from the end :【 The server sends information to the client :Hello World!!!】

  1. The single case mode of the hungry man and the single case mode of the lazy man

1) Take constructor private , The outside world is not allowed to pass through the constructor
Create objects ;
2) Returns a unique instance of a class to the outside world through an open static method

The hungrier singleton :

// Hungry Chinese style Do not delay instantiation , Direct static instantiation creates Ensure thread safety
public class HungarySingleton {
private static HungarySingleton instance=new HungarySingleton();
private HungarySingleton(){
public static HungarySingleton getInstance(){
return instance;// Return unique instance

Lazy singleton pattern :

public class LazySingleton {
private static LazySingleton instance = null;
private Singleton() {}
public static synchronized LazySingleton getInstance(){
if (instance == null) instance = new LazySingleton ();
return instance;

volatile keyword ,DCL Mechanism to achieve lazy , Improve performance

// Slacker type DCL Mechanism
//T1 First copy data from main memory to your own thread memory , To process data , After processing, the data is updated to main memory
//T2 Copy data from main memory to your own thread memory
public class LazySingleton {
private static volatile LazySingleton instance = null;
private LazySingleton(){
//unlock happen-before lock semantics
//T1,T2 --- visibility T1 happen-before T2
* A->B,B->C===A->C
* T2 call getInstance() And call getName()
* T1 call getInstance()
* a++
* T1 ->T2
* Constructor memory operations ->T1 ->T2
public static LazySingleton getInstance(){
//T1 Synchronization All for null You can only enter one , Waiting for execution
instance=new LazySingleton();
//1. Open up space
//2. Initialize object
//3. Give the address to isntance Variable ---CPU
return instance;
  1. Be able to make int Cast to byte A variable of type ? If the value
    Greater than byte The range of types , What will happen ?

You can do a cast , however Java in int yes 32 position (4byte) Of , and byte yes 8 position (1byte) Of , therefore , If the forced conversion is ,int The type of height 24 Bits will be discarded ,byte The range of types is from -128 To 128.

  1. Which class contains clone Method ? yes Cloneable still Object?

java.lang.Cloneable Is a symbolic interface , There's no way , clone Method in object Definition in class . also clone() A method is a local method , This means that it was created by c or c++ Or other local language implementation .

  1. Java in ++ (- -) Are operators thread safe ?

Not a thread safe operation . It involves multiple instructions , Such as reading variable value , increase / Reduce , And then store it back in memory , Multiple threads may cross in this process .

  1. a = a + b And a += b The difference between

+= Implicitly add the result type of the operation Coercive transformation For the type of results held ( such as a += b The result of the calculation will be a+b Convert to need a The corresponding type ). If you add two integers , Such as byte、short perhaps int, First they will be promoted to int type , And then add , Finally, it is converted to the type of data received .
and a = a + b There is no type conversion , If you cross the line, you throw an exception

// byte Value -128 To 128, If you exceed it, you have to convert the type
byte a = 120;
byte b = 120;
a = a + b; // Compiler error :cannot convert from int to byte, Because it will not result in (a+b) Auto cast
a += b; // Compile correctly ,b = -16
// Implicitly cast the result type of the add operation to the type of holding the result (a+b It is implicitly converted to int Add up
// Cast result to receive result a The type of byte,a+b=240(int type ) Convert to a The type of byte=-16)
  1. int and Integer Which will take up more memory

Integer Wrapper classes take up more memory .Integer It's an object , Need to store metadata for object . however int Is a primitive type of data , So it takes up less space

  1. “a==b” and ”a.equals(b)” What's the difference? ?

If a and b Are all objects , be a==b Is a reference to compare two objects , Only when a and b It points to the same object in the heap true,a.equals(b) It's a logical comparison , So it is often necessary to override this method to provide a logical consistency comparison . for example ,String Class rewriting equals() Method , So it can be used for two different objects , But it contains a comparison of the same letters

  1. a.hashCode() What's the usage? ? And a.equals(b) What does it matter ?

hashCode() Method is integral to the corresponding object hash value . It is often based on hash Set class of , Such as Hashtable、HashMap、LinkedHashMap wait . It is associated with equals() Methods are particularly relevant . according to Java standard , Two uses equal() Method to determine equal objects , Must have the same hash code.

  1. Java Collections framework

poll() Methods and remove() Differences in methods

poll() and remove() It's all about taking an element out of the queue , however poll() It will return null if it fails to get the element , however remove() Throw an exception when you fail .

LinkedHashMap and PriorityQueue The difference between

PriorityQueue Ensure that the highest or lowest priority element is always in the queue header , however LinkedHashMap The order maintained is the order in which the elements are inserted . When traversing a PriorityQueue when , There is no sequence guarantee , however LinkedHashMap Ensure that the order of traversal is the order of element insertion .

ArrayList And LinkedList The main difference

ArrrayList The underlying data structure is an array , Support random access , and
LinkedList The underlying data structure of is linked list ( Double linked list ), Random access is not supported ( But the update operation is optimized ). Using subscripts to access an element ,ArrayList The time complexity of is O(1), and LinkedList yes O(n).

Hashtable And HashMap What's the difference

1)Hashtable yes JDK 1 Legacy classes , and HashMap It was added later .
2)Hashtable It's synchronous , It's slow , but HashMap There is no synchronization strategy , So it will be faster .
3)Hashtable It's not allowed to have an empty key, however HashMap Allow one to appear null key.

Java Medium HashSet, How the interior works

HashSet The internal use of HashMap To achieve . because Map need key and value, So all key All of them have a default value. Be similar to HashMap, HashSet Repetition is not allowed key, Only one is allowed null key, It means HashSet Only one... Can be stored in null object .

ArrayList and HashMap Default size of

ArrayList The default size is 10 Elements , HashMap The default size is 16 Elements ( Must be 2 The power of )

Of two identical objects hash code It must be the same , Two objects have the same hash Code, But the two objects are not necessarily the same .

Two unequal objects may have the same hashcode value , Is that why hashmap There will be conflicts . equal hashcode The value is only specified if two objects are equal , There must be the same hashcode value , But there is no rule about unequal objects

Java Medium TreeMap It is realized by using red black tree .

 The author of this article :strive_day
Link to this article :

More information, please pay attention to the official account :「 Software Laowang 」, Focus on not getting lost , Software Lao Wang and his IT friends , Share some of their technical insights and life stories .

本文为[Software King]所创,转载请带上原文链接,感谢

  1. 【计算机网络 12(1),尚学堂马士兵Java视频教程
  2. 【程序猿历程,史上最全的Java面试题集锦在这里
  3. 【程序猿历程(1),Javaweb视频教程百度云
  4. Notes on MySQL 45 lectures (1-7)
  5. [computer network 12 (1), Shang Xuetang Ma soldier java video tutorial
  6. The most complete collection of Java interview questions in history is here
  7. [process of program ape (1), JavaWeb video tutorial, baidu cloud
  8. Notes on MySQL 45 lectures (1-7)
  9. 精进 Spring Boot 03:Spring Boot 的配置文件和配置管理,以及用三种方式读取配置文件
  10. Refined spring boot 03: spring boot configuration files and configuration management, and reading configuration files in three ways
  11. 精进 Spring Boot 03:Spring Boot 的配置文件和配置管理,以及用三种方式读取配置文件
  12. Refined spring boot 03: spring boot configuration files and configuration management, and reading configuration files in three ways
  13. 【递归,Java传智播客笔记
  14. [recursion, Java intelligence podcast notes
  15. [adhere to painting for 386 days] the beginning of spring of 24 solar terms
  16. K8S系列第八篇(Service、EndPoints以及高可用kubeadm部署)
  17. K8s Series Part 8 (service, endpoints and high availability kubeadm deployment)
  18. 【重识 HTML (3),350道Java面试真题分享
  19. 【重识 HTML (2),Java并发编程必会的多线程你竟然还不会
  20. 【重识 HTML (1),二本Java小菜鸟4面字节跳动被秒成渣渣
  21. [re recognize HTML (3) and share 350 real Java interview questions
  22. [re recognize HTML (2). Multithreading is a must for Java Concurrent Programming. How dare you not
  23. [re recognize HTML (1), two Java rookies' 4-sided bytes beat and become slag in seconds
  24. 造轮子系列之RPC 1:如何从零开始开发RPC框架
  25. RPC 1: how to develop RPC framework from scratch
  26. 造轮子系列之RPC 1:如何从零开始开发RPC框架
  27. RPC 1: how to develop RPC framework from scratch
  28. 一次性捋清楚吧,对乱糟糟的,Spring事务扩展机制
  29. 一文彻底弄懂如何选择抽象类还是接口,连续四年百度Java岗必问面试题
  30. Redis常用命令
  31. 一双拖鞋引发的血案,狂神说Java系列笔记
  32. 一、mysql基础安装
  33. 一位程序员的独白:尽管我一生坎坷,Java框架面试基础
  34. Clear it all at once. For the messy, spring transaction extension mechanism
  35. A thorough understanding of how to choose abstract classes or interfaces, baidu Java post must ask interview questions for four consecutive years
  36. Redis common commands
  37. A pair of slippers triggered the murder, crazy God said java series notes
  38. 1、 MySQL basic installation
  39. Monologue of a programmer: despite my ups and downs in my life, Java framework is the foundation of interview
  40. 【大厂面试】三面三问Spring循环依赖,请一定要把这篇看完(建议收藏)
  41. 一线互联网企业中,springboot入门项目
  42. 一篇文带你入门SSM框架Spring开发,帮你快速拿Offer
  43. 【面试资料】Java全集、微服务、大数据、数据结构与算法、机器学习知识最全总结,283页pdf
  44. 【leetcode刷题】24.数组中重复的数字——Java版
  45. 【leetcode刷题】23.对称二叉树——Java版
  46. 【leetcode刷题】22.二叉树的中序遍历——Java版
  47. 【leetcode刷题】21.三数之和——Java版
  48. 【leetcode刷题】20.最长回文子串——Java版
  49. 【leetcode刷题】19.回文链表——Java版
  50. 【leetcode刷题】18.反转链表——Java版
  51. 【leetcode刷题】17.相交链表——Java&python版
  52. 【leetcode刷题】16.环形链表——Java版
  53. 【leetcode刷题】15.汉明距离——Java版
  54. 【leetcode刷题】14.找到所有数组中消失的数字——Java版
  55. 【leetcode刷题】13.比特位计数——Java版
  56. oracle控制用户权限命令
  57. 三年Java开发,继阿里,鲁班二期Java架构师
  58. Oracle必须要启动的服务
  59. 万字长文!深入剖析HashMap,Java基础笔试题大全带答案
  60. 一问Kafka就心慌?我却凭着这份,图灵学院vip课程百度云