title: Console class java
body: <pre><code>import java.io.Console; 
  
  public class Talk {
      public static void main(String[] args) {
          Console c = System.console();
          String pw;
          System.out.print("password: ");
          pw = c.readLine();
          System.out.println("got " + pw);
      }
  }
  </code></pre>
  
  <p>Why am I getting exception in above code?</p>
  
  <pre><code>password: Exception in thread "main" java.lang.NullPointerException
      at Talk.main(Talk.java:8)
  </code></pre>
  
  <p>Can anyone help me out?</p>