I am working with JavaFX and i am trying to add to an ArrayList class from the controller file so when the create button is pressed on the FXML file the controller adds a person object to a class of contacts which is an arrayList however i want the ArrayList class Contacts to be global so i could edit whatever is in or has been added to the list later on
Person class:
package project1;
/**
 *
 * @author Fomnus
 */
public class Person {
    private String firstName;
    private String lastName;
    /**
     * Constructor with parameter
     *
     * @param firstName
     * @param lastName
     */
    public Person(String firstName, String lastName) {
        this.firstName = firstName;
        this.lastName= lastName;
    }
    /**
     * Method to get the name of person
     */
    public String getFirstName() {
        return firstName;
    }
    public String getLastName() {
        return lastName;
    }
    /**
     * Method to set the name of person
     */
    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }
    public void setLastName(String lastName) {
        this.lastName = lastName;
    }
}
Contacts class ArrayList:
package project1;
import java.util.ArrayList;
import java.util.List;
/**
 *
 * @author Fomnus
 */
public class Contacts {
    public static void main(String args[]) {
      // create an array list
      ArrayList contactsList = new ArrayList();
      Person person1= new Person("John", "Doe");
      Person person2= new Person("Jane", "Rivers");
      Person person3= new Person("Steve", "Smith");
      Person person4= new Person("Lucy", "White");
      contactsList.add(person1);
      contactsList.add(person2);
      contactsList.add(person3);
      contactsList.add(person4);
   }
}
