Adding a class to an ArrayList, but got NullPointerException : <p>So, I was trying to add a class to an ArrayList, but when I do it gives me a Null Pointer Exception. I'm sure I am just overlooking a variable that I thought was initialized, but I can't figure it out. </p>

<p>This is the class:</p>

<pre><code>enum WebType { GoogleResult, Webpage };
public class Webpage {

WebType type;

String pageName;
String content;
String url;
String MLA = "";

public Webpage(String pageName, String content, String url, WebType type){
    this.type = type;
    this.pageName = pageName;
    this.content = content;
    this.url = url;
    this.MLA = ""; // Temp
}

// TODO: Make Citation Maker
</code></pre>

<p>}</p>

<p>This is where I add the class to the ArrayList:</p>

<pre><code>    public void Start(){
    for(Integer i = 0; i &lt; tags.size(); i++){
        if(tags.get(i) == null)
            return;
        Webpage page = Google(tags.get(i));
        parseList.add(page); // The Error is on this line!
        log.append("Added " + page.url + " to parse list");
    }
    for(Integer i = 0; i &lt; parseList.size(); i++){
        ParsePageCode(parseList.get(i));
    }
}
</code></pre>

<p>Here is the Google function, it googles whatever you tell it to and returns the page information:</p>

<pre><code>    public Webpage Google(String search){
    String url = "https://www.google.com/search?q=" + search;
    String content = "";
    try {
        URLEncoder.encode(url, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        log.append("\n Unsupported Encoding Contacting Google");
    }
    try {
        content = GetPageCode(url);
    } catch (IOException e) {
        log.append("\n Unable To Reach Google");
        log.append(e.getMessage());
    }
    Webpage w = new Webpage("Google Result For " + search, content, url, WebType.GoogleResult);
    // System.out.println(search + url + WebType.GoogleResult);
    return w;
}
</code></pre>

<p>Any Ideas?</p>
