public class Album {
private String albumtitle;
private ArrayList<Photo> photos;
/**
* This constructor should initialize the
* instance variables of the class.
*/
public Album(String title) {
this.albumtitle = title;
photos = new ArrayList<>();
}
问题是它一直说“.contains 有一个字符串”这在方法头类型和参数类型相同时有效。我必须以某种方式转换吗?
public Photo searchByTitle(String title) {
for(Photo photo : photos) {
if (photo.contains(title)){
return photo;
}
return null;
}
}
简短的问题。谢谢
慕标琳琳
慕田峪4524236
相关分类