Hello,
I'm working on a project, where a person enters a bakkery. If the person has a VIP pass it will stand in row 1, if not, the person will stand in row 2. I need to use the ArrayList in order to register the persons in the bakery.
The class of Person registers the name and VIP pass. I'm trying to code it like below, but I get the NullPointerException in the line row1.add(name);
What am I doing wrong, or is there a different way to get the person into the right row?
Thanks in advance!
public class Bakery { // instance variables private String name; private ArrayList<Person> client; private ArrayList<Person> row1; private ArrayList<Person> row2; /** * Constructor for objects of class Bakery */ public Bakery (String name) { this.name = name; client = new ArrayList<Person> (); } public void enterBakery (Person name) { if (name.hasVIPpass() == true) { row1.add(name); } else { row2.add(name); } }