package test.arithmetic; /** * 接口中定义泛型 * @author Administrator * */ public class Arithmetic1 { /** * @param args */ public static void main(String[] args) { Point<String> p=new PointImpl<String>("20度,110度"); print(p); } public static void print(Object p){ System.out.println(p); } } interface Point<T>{ public T getPoint(); } class PointImpl<T> implements Point<T>{ private T point; public PointImpl(T point){ this.setPoint(point); } public void setPoint(T point){ this.point=point; } @Override public T getPoint() { return point; } @Override public String toString() { // TODO Auto-generated method stub return point.toString(); } }