如题所示,想通过继承GeoResult类来扩展属性//GeoResult 类public class GeoResult implements Serializable { private static final long serialVersionUID = 1637452570977581370L; private final T content; private final Distance distance; public GeoResult(T content, Distance distance) { Assert.notNull(content, "Content must not be null!"); Assert.notNull(distance, "Distance must not be null!"); this.content = content; this.distance = distance; }}//扩展GeoResult类public class GeoExtendResult extends GeoResult implements Serializable{ private String str; public GeoExtendResult(T content, Distance distance, String str) { this.str = "abc"; super(content, distance); } public String getStr() { return str; } public void setStr(String str) { this.str = str; }}//这是正确的List geoResultList = radiusGeo.getContent();//报类型不匹配List geoResultList = radiusGeo.getContent(); |