1. public interface 接口名<泛型表示符号>{
    2. }

    举例:

    1. public interface Student1<T> {
    2. T getName(T name);
    3. }
    1. public class StudentImpl implements Student1<String>{
    2. @Override
    3. public String getName(String name) {
    4. return name;
    5. }
    6. }
    1. public class Test1 {
    2. public static void main(String[] args) {
    3. Student1<String> stu1 = new StudentImpl(); // 接口类型的实例化对象需要指定具体的数据类型,否则就是object
    4. System.out.println(stu1.getName("爱摸鱼的TT~"));
    5. StudentImpl stu2 = new StudentImpl(); // 实现类类型的实例化对象就不需要指定具体的数据类型
    6. System.out.println(stu2.getName("爱摸鱼的TT"));
    7. }
    8. }