public class Point
private T x;
private T y;
public Point(T x, T y) {
this.x = x;
this.y = y;
}
public T getX() {
return x;
}
public void setX(T x) {
this.x = x;
}
public T getY() {
return y;
}
public void setY(T y) {
this.y = y;
}
public void outPut(Point
System.out.println("点的x坐标为:"+p.getX());
System.out.println("点的y坐标为:"+p.getY());
}
public static void main(String[] args) {
Point
p.outPut(p);
Point
d.outPut(d);
Point
f.outPut(f);
}
}
泛型,通俗点就是提前声明这个list中将来到底装什么东西
lines的泛型为list
list的泛型又是Point对象
通俗说法:lines中存放一堆list列表
而每个list中又存放一堆Point对象
跟多维数组很类似:
lines1
---list1
----Point1
----Point2
----Point3
----Point4
---list2
----Point5
----Point6
----Point7
----Point8
lines2
---list2
----Point1
----Point2
----Point3
----Point4
---list3
----Point5
----Point6
----Point7
----Point8