Home > Java > javaTutorial > What are the precautions for using java generic interface?

What are the precautions for using java generic interface?

WBOY
Release: 2023-04-25 10:46:06
forward
1610 people have browsed it

Usage Notes

1. The implementation class is not a generic class, and the interface must have a clear data type.

2. The implementation class is also a generic class, so the generic types must be consistent.

3. Generic type parameters can only be class types, not simple types. The instanceof operation cannot be used on exact generic types.

Example

interface Info<T>{
    public T getValue();
}
 
class InfoImpl implements Info {
    public String getVar() {
        return null;
    }
}
Copy after login

What are the basic data types of java

The basic data types of Java are divided into:

1. Integer type , a data type used to represent integers.

2. Floating point type, a data type used to represent decimals.

3. Character type. The keyword of character type is "char".

4. Boolean type is the basic data type that represents logical values.

The above is the detailed content of What are the precautions for using 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