i have been asked to create a method that is capable of inserting a "Person" class into an ArrayList of persons. but all it says is that the types are incompatible. starting to think that the add method might not work in this situation. any advise would be greatly appreciated! thank you in advance.

import java.util.ArrayList;

public class DikuPlus
{
    private Person person;
    private ArrayList<Person> network;
    
    public void DikuPlus(ArrayList<Person> network)
    {
        this.network = network;
    }
    
    public ArrayList<Person> addPerson(Person person)
    {
        this.network = network.add(person);
    }
}

Look up the return type of ArrayList.add(). Why are you trying to assign that to your ArrayList variable?

would this solve the problem? and thank you for being so fast, once again:)

import java.util.ArrayList;

public class DikuPlus
{

    private ArrayList<Person> network;
    
    public void addPerson(Person person)
    {
        network.add(person);
    }

Good question. Did it solve the problem? Does the method do what you intend?