In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what is the inheritance and implementation of Java generics". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the inheritance and implementation of Java generics"?
A little bit of eye contact
Once generic classes and generic interfaces are defined, they can be inherited and implemented.
Inheritance of two generic classes
1 code
Class A {E t;} public class Bextends A {public static void main (String [] args) {System.out.println ("B test");}}
2 run
B test
3 description
When subclass B is defined, if An is omitted, the T of B automatically becomes Object. It is recommended to add it when defining to retain the type parameters of the parent class. Class B can also add a new generic T1.
Implementation of three generic interfaces
1 code
Interface IT {public E dis ();} public class testIT implements IT {E e; public testIT (E) {this.e = e;} public E dis () {return e;} public static void main (String [] args) {testIT tt = new testIT ("test"); System.out.println (tt.dis ());}}
2 run
Test
3 description
The implementation class testIT cannot be omitted.
You must implement all the methods in the IT interface, just like the normal implementation class.
Thank you for reading, the above is the content of "what is the inheritance and implementation of Java generics". After the study of this article, I believe you have a deeper understanding of what is the inheritance and implementation of Java generics, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.