Can't get out of the loop when I type nothing or press cancel
<p>I can't seem to get out of the loop when I type nothing in the input or I press cancel.
Is there a way out?</p>

<pre><code>    While (last == '?'){
        input = (int)(Math.random()*2); 
        if (number == 1){
            answer = "Nice";
        }
        if (number == 2){
            answer = "Okay";
        }
        System.out.println("The answer: " + answer);
        input = JOptionPane.showInputDialog(null, "Ask a question. (Remember the?)");
        if (input != null &amp;&amp; input.length() &gt; 0){
            last = input.charAt(input.length() - 1);
        }
    }
</code></pre>
