---
title: "Java泛型接口"
author: "cjx186"
date: "2012-09-16T17:40:25Z"
tags: []
categories: ["编程语言"]
slug: "java"
draft: false
lastmod: "2012-09-16T17:40:25Z"
id: 1679448
url: "https://xml.iteye.com/blog/1679448"
---

```java
package me.cjx.example;
interface Demo<T> {
    public void print(T param);
}
// 实现泛型接口一
class Imple1<T> implements Demo<T> {
    public void print(T param) {
        System.out.println("param = " + param);
    }
}
// 实现泛型接口二
class Imple2 implements Demo<Imple2> {
    public void print(Imple2 param) {
        System.out.println("param = " + param);
    }
}
public class GenericsDemo {
    public static void main(String[] args) {
        Imple1<String> demo = new Imple1<String>();
        demo.print("Hello, Wrold!");
        Imple2 im = new Imple2();
        im.print(new Imple2());
    }
}

```