Access arraylist from another class inside main class : <p>I don't have any idea on how to make this since i'm a new in java. I want to display all my objects in the arraylist of my TimeSlot class into the main class. I've tried few ways like using for (int = 0; i &lt; bookingList.size(); i++) but still can't work. I'm getting nullPointerException so i dont know if there's other way to solve this. Please help.</p>

<p>TimeSlot.java</p>

<pre><code>import java.util.ArrayList;

public class TimeSlot {

    private String slotName;
    private ArrayList&lt;Booking&gt; bookingList;


    public TimeSlot(String sn) {

        this.slotName = sn;
        this.bookingList = new ArrayList&lt;Booking&gt;();

        Booking booking1 = new Booking("CS1011", "A04", "Aiman");
        Booking booking2 = new Booking("CS1012", "A13", "Nazim");
        Booking booking3 = new Booking("CS1013", "A06", "Sarah");
        Booking booking4 = new Booking("CS1014", "A21", "Majid");

        bookingList.add(booking1);
        bookingList.add(booking2);
        bookingList.add(booking3);
        bookingList.add(booking4);



    }

    public String getSlotName() {
        return slotName;
    }

    public ArrayList&lt;Booking&gt; getBookingList() {
        return bookingList;
    }

    public boolean isBooking (String bId, String cId, String sId) {
        boolean isVerifyBooking = false;
        for(Booking newBooking: bookingList){
            if((newBooking.getBookingId().equals(bId)) &amp;&amp; newBooking.getComputerId().equals(cId) &amp;&amp; newBooking.getStudentId().equals(sId)) {
                return true;
            }
        }
            return isVerifyBooking;
    }

}
</code></pre>

<p>Main.java</p>

<pre><code>public static void main(String[] args) {

        // TODO Auto-generated method stub
        Faculty faculty = new Faculty("Computer Science and Technology", "");
        Lab lab = new Lab("");
        ArrayList&lt;Computer&gt; computerList = new ArrayList&lt;Computer&gt;();
        ArrayList&lt;Booking&gt; isBookingList = new Booking(null, null, null).getBookingList();

           if (option.equals("1")) {

             System.out.println("\nChoose day: ");
             String days = sc.next();
             System.out.println("\nChoose date: ");
             String date = sc.next();

             boolean isValidDay = lab.verifyDate(days, date);

             if (isValidDay) {
               Day day = new Day(days, date);
               System.out.println("\nBooking date: " + day.getDay() + " " + day.getDate());
               System.out.println("\nPlease select a computer (A01 ~ A40): ");
               String cId = sc.next();

              System.out.println(isBookingList.size());
            }
          } else if (option.equals("2")) {

          // I want to display it here

          for (Booking booking: isBookingList) {
            System.out.println(booking.getBookingList());
         }
      }
</code></pre>
