I have a Project
class, which contains non-static ArrayList of Issue
object
public class Project{
private ArrayList<Issue> issue_Array = new ArrayList<>();
//method to remove Issue
public void removeIssue(Issue issue_obj) {
this.issue_Array.remove(issue_obj);
}
}
And here's the Issue
class
public class Issue {
public void deleteThisIssue() {
Project.removeIssue(this); //this is where I don't know
}
}
I was finding a way for the Issue object to remove itself from its ArrayList in another class. My approach is to call the removeIssue()
method from the Project
class and pass this
. But then I realize I can't declare ArrayList<Issue>
as static since different Project
stores different ArrayList<Issue>
, how am I able to remove the Issue itself from its ArrayList stored in another class?