Home > Java > javaTutorial > body text

How to use java generic interface

WBOY
Release: 2023-04-18 09:37:02
forward
986 people have browsed it

1. Description

When the generic parameter is not passed in to the generic interface, it is the same as the definition of the generic class. When declaring the class, the generic declaration needs to be Also added to the class.

If a generic interface passes in type parameters and implements the implementation class of the generic interface, all uses of generics must be replaced with the passed in actual parameter types.

2. Examples

/* 即:class DataHolder implements Generator<T>{
 * 如果不声明泛型,如:class DataHolder implements Generator<T>,编译器会报错:"Unknown class"
 */
class FruitGenerator<T> implements Generator<T>{
    @Override
    public T next() {
        return null;
    }
}
Copy after login

What are the commonly used java frameworks

1.SpringMVC, Spring Web MVC is a Java-based implementation of the Web A lightweight web framework based on the request-driven MVC design pattern.

2.Shiro, Apache Shiro is a security framework for Java.

3.Mybatis, MyBatis is an excellent persistence layer framework that supports ordinary SQL queries, stored procedures and advanced mapping.

4.Dubbo, Dubbo is a distributed service framework.

5.Maven, Maven is a project management and build automation tool.

6.RabbitMQ, RabbitMQ is a high-concurrency and high-reliability AMQP message queue server implemented in Erlang.

7.Ehcache, EhCache is a pure Java in-process caching framework.

The above is the detailed content of How to use java generic interface. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template