当前位置:网站首页>The first day of handwritten RPC -- review of some basic knowledge
The first day of handwritten RPC -- review of some basic knowledge
2022-06-24 21:19:00 【datoooooou】
Start preparing your resume today , That is to say, those who are going to ruin the street rpc
Learning content :
Thank you first Guide Brother provides us with ideas :
https://github.com/CN-GuoZiyang/My-RPC-Framework;
Then there is the more easy to understand version written by brother Sheng :
https://github.com/CN-GuoZiyang/My-RPC-Framework;
Finally, a comment version shared by brother Niuke ( The kind of food that comes to your mouth ):https://github.com/IAMPadA/Panda-Rpc-Framework/tree/master
It's a pity that even if I knock on other people's projects, there will still be a lot of things confused , Eh, this <> It's something , Oh, like before javaSE I heard from Master Kang that it is called generics , What's a question mark in it ???
OK This concludes today's project , Let's go and figure out the generics first , Otherwise, all the methods are well written
Learning output :
After passing Niuke 、CSDN、 And another baptism of Master Kang , It's probably to make the generics clear , Incidentally, I also read the common interview questions , Here I recommend a blog that speaks a lot :
https://blog.csdn.net/s10461/article/details/53941091?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522164527353216780255238521%2522%252C%2522scm%2522%253A%252220140713.130102334…%2522%257D&request_id=164527353216780255238521&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2alltop_positive~default-1-53941091.first_rank_v2_pc_rank_v29&utm_term=%E6%B3%9B%E5%9E%8B&spm=1018.2226.3001.4187
My summary is as follows :
Generics are also called “ Parameterized types ”, It's about defining classes 、 Interface 、 Method to specify a specific type , Let class 、 Interface 、 Method to decide which type of parameter to use .
Java The generics of are in 1.5 Introduced , Only do generic checking at compile time , Runtime generics will disappear , We call this “ Generic erase ”, Eventually, the type will become Object. Before there are no generics , Every object read from the collection must be typed , If you accidentally insert the wrong type object , There will be errors in the transformation processing at run time , With generics , You can tell the compiler what type of object each collection receives , The compiler does type checking at compile time , Tells if an object of the wrong type has been inserted , Make the program more secure , And more clearly .
Generics are used in three ways , Respectively : Generic classes 、 Generic interface 、 Generic methods .
Generic class writing : Class name <T> among T Represents a type name , I could just write , When instantiating, you must specify the specific type , A generic type parameter can only be a class type ( Including custom classes ), It can't be a simple type , That is, it cannot be int, It is Integer.
At the same time pay attention to : Generic types of classes cannot be used in static methods , It can be understood that the static structure is earlier than the creation of the class , Generics know the type only when they are instantiated , So it will report a mistake ; In addition, exception classes cannot be generic .
For multiple types, the declaration method is : Class name <T1,T2>
Generic interface : It is basically consistent with generic classes , The difference is that subclasses need to declare generic types at the interface when inheriting generic interfaces , Otherwise the compiler reports an error .
Generic methods : That is, generic structures appear in methods , It's different than before , Generic methods can be declared static , Because generic parameters are determined when a method is called , Instead of instantiating , The usual definition is :
Such as public <T> List<T> add(T[] arr)
Generics in terms of inheritance , if A yes B Parent class of ,G<A> and G<B> There is no parent-child relationship , It's a juxtaposition .
Finally, wildcards “?” Use , It can be understood as a common parent of two generics , Above AB The common parent of is G<?>, But you can't add any data to it (NULL With the exception of ), Similar to abstract classes .
The above is an unbounded wildcard , That is, there are no restrictions , There is also a restricted wildcard ,
It can be simply understood as :extends T Only generics are allowed to be T And its subclasses call
super T Only generics are allowed to be T Class and its parent class call 
It seems that 80% of them are so many , People are numb , When you are empty, look back and see if there is any mistake
边栏推荐
- Address mapping of virtual memory paging mechanism
- The difference between RPC and restful
- Create a multithreaded thread class
- GDB debugging
- data link layer
- Summary of message protocol problems
- 大厂出海,败于“姿态”
- opds sql组件能不能将流程参数通过上下文传给下一个组件
- Web automation: summary of special scenario processing methods
- Open function
猜你喜欢

Berkeley, MIT, Cambridge, deepmind et d'autres grandes conférences en ligne: vers une IA sûre, fiable et contrôlable

After idea installs these plug-ins, the code can be written to heaven. My little sister also has to arrange it
[email protected] -Perfmon metric collector listener steps"/>JMeter installation plug-in, adding [email protected] -Perfmon metric collector listener steps

Haitai Advanced Technology | application of privacy computing technology in medical data protection

Shrimp skin test surface treated

Limit summary (under update)

Create a multithreaded thread class

伯克利、MIT、劍橋、DeepMind等業內大佬線上講座:邁向安全可靠可控的AI

It was Tencent who jumped out of the job with 26k. It really wiped my ass with sandpaper. It gave me a hand

Bean lifecycle flowchart
随机推荐
Undo log and redo log must be clear this time
Curl command
PHP script calls command to get real-time output
After idea installs these plug-ins, the code can be written to heaven. My little sister also has to arrange it
Golang reflection operation collation
Format method and parse method of dateformat class
JUnit unit test
Learn together and make progress together. Welcome to exchange
Background operation retry gave up; KeeperErrorCode = ConnectionLoss
[cloud native learning notes] kubernetes Foundation
database/sql
Leetcode (146) - LRU cache
What does virtualization mean? What technologies are included? What is the difference with private cloud?
After screwing the screws in the factory for two years, I earned more than 10000 yuan a month by "testing" and counterattacked
Berkeley, MIT, Cambridge, deepmind and other industry leaders' online lectures: towards safe, reliable and controllable AI
Microsoft Certification (dynamic 365) test
How to apply agile development ideas to other work
[performance tuning basics] performance tuning strategy
It was Tencent who jumped out of the job with 26k. It really wiped my ass with sandpaper. It gave me a hand
Interpreter mode -- formulas for dating