NullPointerException despite specifying : <p>I want to code a personal modloader for minecraft (create files , download files, sort files, etc) and the first window which is created is a JOptionPane which asks for a Version (i do not code in java really long, i don´t use spinner, just a "msg dialog" asking for a version). The code is:</p>

<pre><code>public JOptionPane version = new JOptionPane();
public String modversion;

public Version()
{
    showVersion();
}

public static void main(String[] args)
{

}

public void showVersion()
{
    //input = version
    String vers = version.showInputDialog("Welche Version soll modifiziert werden?");

    if (vers.equals(null)) {
            return;
    } else { 
        if(vers.equals("1.5.2") || vers.equals("1.6.2") || vers.equals("1.6.4") || vers.equals("1.7.2") || vers.equals("1.7.10") || vers.equals("1.8") || vers.equals("1.8.9") || vers.equals("1.9") || vers.equals("1.10.2") || vers.equals("1.11.2"))
        {

          //mod version is saved as String (title for the config list)

            modversion = vers;
            return;
        } else  {
           // with incompatible input the method will be repeated
            JOptionPane.showMessageDialog(null, "Diese Version wird leider nicht supportet");
            showVersion();
        }
    }
}
</code></pre>

<p>If you just press "Ok", the input would equal "null":</p>

<pre><code>if (vers.equals(null)) {
            return;
    }
</code></pre>

<p>but it don´t quit the method, it says NullPointerException. Why doesn´t it just quit the method?</p>
