0

This is the class where I'm getting null pointer exception Presenter.java


    Display d;

    interface Display
    {       
        public List<String> getLists();             
    }

    public void output()
    {
        List<String> out = d.getLists(); // getting null pointer here
        for(int i=0;i<out.size();i++)
        {
            System.out.println(out.get(i));         
        }
    }

    public static void main(String[] a)
    {

        Presenter p = new Presenter();
        p.output();
    }

}

I'm implementing the interface Display in the class below, and returning the newList as below.

View.java

public class View implements Presenter.Display {

    String[] a = {"London","Paris","New York"};

    List<String> newList = new ArrayList<String>(Arrays.asList(a));

    @Override
    public List<String> getLists() {

        return newList;
    }
}

I've looked through several examples but I'm not getting how to get the value of getLists() method in the presenter class.

What am I missing here ? Please help

0 Answers0