I am trying to add objects to my ArrayList friends... I get this error,
The method add(int, Person) in the type ArrayList is not applicable for the arguments (int, String)
I am trying to add a few instances of my person object to eventually create a tree of friends.
import java.util.*;
public class Person
{
public int id; // some identification number unique to the person
public boolean zombie; // true if the person is a zombie
public char state; // p means human, z means zombie
public static ArrayList<Person> friends; // list of friends
public Person(int id, char state)
{
this.id = id;
this.state = state;
//this.zombie = zombie;
}
public static void addPeople()
{
friends = new ArrayList<Person>();
friends.add(1, 'p');
}
public boolean isZombie()
{
if (state == 'p')
{
return zombie=false;
}
else if (state == 'z')
{
return zombie=true;
}
return zombie;
}
}
The error is located under the "add" word. I would also like to know how I can name the instances of the object so I only call the name rather than the two attributes.
Thanks in advance for all help.
friendsevery time, you delete old entries.