当前位置:网站首页>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
边栏推荐
- Packaging_ Conversion between basic type and string type
- Use the transparent [x] cross button image in the dialog
- Can the OPDS SQL component pass process parameters to the next component through context
- An example illustrates restful API
- After screwing the screws in the factory for two years, I earned more than 10000 yuan a month by "testing" and counterattacked
- Subnet partition operation
- Physical layer introduction
- Combination mode -- stock speculation has been cut into leeks? Come and try this investment strategy!
- Haitai Advanced Technology | application of privacy computing technology in medical data protection
- Memo mode - game archiving
猜你喜欢
Berkeley, MIT, Cambridge, deepmind et d'autres grandes conférences en ligne: vers une IA sûre, fiable et contrôlable
Memo mode - game archiving
Berkeley, MIT, Cambridge, deepmind and other industry leaders' online lectures: towards safe, reliable and controllable AI
大厂出海,败于“姿态”
Procedural life: a few things you should know when entering the workplace
yeb_ Back first day
Responsibility chain mode -- through interview
主数据建设的背景
Bridging mode -- law firm
Simple analysis of WordPress architecture
随机推荐
Network flow 24 questions (round table questions)
A/B测试助力游戏业务增长
Alibaba cloud schedules tasks and automatically releases them
Steps of JMeter performance test
Geek University cloud native training camp
Shrimp skin test surface treated
Golang reflection operation collation
Builder mode -- Master asked me to refine pills
Static routing job
DAPP system customization of full chain hash game (scheme design)
Combination mode -- stock speculation has been cut into leeks? Come and try this investment strategy!
A/b test helps the growth of game business
Format method and parse method of dateformat class
Tool composition in JMeter
Talking about the range of data that MySQL update will lock
How to apply agile development ideas to other work
Enjoy yuan mode -- a large number of flying dragons
Leetcode (146) - LRU cache
Limit summary (under update)
虚拟化是什么意思?包含哪些技术?与私有云有什么区别?