泛型练习4(接口)

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();
	}
	
}


posted @ 2015-03-29 09:40  mfrbuaa  阅读(135)  评论(0编辑  收藏  举报