Home >Java >javaTutorial >How to use java generic interface

How to use java generic interface

WBOY
WBOYforward
2023-04-18 09:37:021008browse

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;
    }
}

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete