当前位置:网站首页>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
边栏推荐
- [cloud native learning notes] kubernetes practice command
- Leetcode (455) - distribute cookies
- Requests requests for web page garbled code resolution
- Is the waiting insurance record a waiting insurance evaluation? What is the relationship between the two?
- Pytest testing framework
- 主数据建设的背景
- Talking about the range of data that MySQL update will lock
- Subnet partition operation
- What will you do if you have been ignored by your leaders at work?
- Jar package operation
猜你喜欢

Enjoy yuan mode -- a large number of flying dragons

Limit summary (under update)

B站带货当学新东方

Simple analysis of WordPress architecture

Static routing job

JMeter basic learning records

Bridging mode -- law firm

Page replacement of virtual memory paging mechanism

网络安全审查办公室对知网启动网络安全审查

Prototype mode -- clone monster Army
随机推荐
[cloud native learning notes] kubernetes Foundation
[performance tuning basics] performance tuning standards
Mr. Hu Bo, CIO of weiduomei, a scientific innovator: digitalization is a bloodless revolution, and the correct answer lies in the field of business
红象云腾完成与龙蜥操作系统兼容适配,产品运行稳定
database/sql
Golang reflection operation collation
data link layer
Bridging mode -- law firm
Limit summary (under update)
Alibaba cloud schedules tasks and automatically releases them
How to apply agile development ideas to other work
Curl command
The difference between RPC and restful
Jar package operation
Basic database syntax learning
Geek University cloud native training camp
DHCP operation
After screwing the screws in the factory for two years, I earned more than 10000 yuan a month by "testing" and counterattacked
OSI notes sorting
Address mapping of virtual memory paging mechanism