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
  • 24,730
  • 11
  • 100
  • 106

0 Answers0