Typecasting in java
<pre><code>int n ;
n= (int)( javax.swing.JOptionPane.showInputDialog(null,"enter a 3 digit no."));
</code></pre>

<p>Why does the above gives error[required int, found string] and the below one works fine ?</p>

<pre><code>int n ;
n= Integer.parseInt( javax.swing.JOptionPane.showInputDialog(null,"enter a 3 digit no."));
</code></pre>
