あなたが次のようで、あなたが以下の私のクラスに似ているSubscriber
と仮定します。Course
次のようなことを試すことができます
public class Subscriber {
private List<Course> courses=new ArrayList<>();
public List<Course> getCourses() {
return courses;
}
public void setCourses(List<Course> courses) {
this.courses = courses;
}
}
.
public class Course {
private int courseId;
private String courseName;
public int getCourseId() {
return courseId;
}
public void setCourseId(int courseId) {
this.courseId = courseId;
}
public String getCourseName() {
return courseName;
}
public void setCourseName(String courseName) {
this.courseName = courseName;
}
}
要素を削除しましょう。
List<Subscriber> subscribers=new ArrayList<>();
List<Course> courses=new ArrayList<>();
Subscriber subscriber=new Subscriber();
Course course=new Course();
course.setCourseId(1);
course.setCourseName("one");
courses.add(course);
subscriber.setCourses(courses);
subscribers.add(subscriber);
for (Subscriber i:subscribers){
i.getCourses().remove(0); // remove 0 index element
}