论坛首页 入门技术论坛

A simple sample show generic interface usage

浏览 1645 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2007-09-06  
generic class is common so far, but generic interface is a little bit confused, the program below make concept clearly:

public interface Ia<E> {
    public void add(E element);
    public E get();
}

public interface Ib<T> extends Ia<T> {
    public void myString();
}

public class B<F> implements Ib<F>{

    public void myString() {

    }

    public void add(F element) {

    }

    public F get() {
        return null;
    }

    public static void main(String[] args) {
        B<String> myB = new B<String>();
        myB.toString();
    }

}

论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics