0
public interface Photo {
}

class PlacePhoto implements Photo{}

class PlaceDetail {
  public PlaceDetail(List<Photo> photos)
}

List<PlacePhoto> placePhotos = new ArrayList<PlacePhoto>();

The below line fails type checking: expected argument (List<Photo>) cannot be applied to actual (List<PlacePhoto>)

PlaceDetail placeDetail = new PlaceDetail(placePhotos);

If PlacePhoto implements Photo, why can I not use it for a Photo parameter?

Baker
  • 17,754
  • 6
  • 78
  • 86

0 Answers0