Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>via: <a href="http://www.codeguru.com/forum/showthread.php?t=487190" rel="nofollow noreferrer">http://www.codeguru.com/forum/showthread.php?t=487190</a> for detail</p> <p>Before using a method it always pays to read the API documents on what the method does. For example docs for the console() method say:</p> <p>Quote:</p> <blockquote> <p>Whether a virtual machine has a console is dependent upon the underlying platform and also upon the manner in which the virtual machine is invoked. If the virtual machine is started from an interactive command line without redirecting the standard input and output streams then its console will exist and will typically be connected to the keyboard and display from which the virtual machine was launched. If the virtual machine is started automatically, for example by a background job scheduler, then it will typically not have a console. </p> <p>If this virtual machine has a console then it is represented by a unique instance of this class which can be obtained by invoking the System.console() method. If no console device is available then an invocation of that method will return null.of that method will return null.</p> </blockquote> <p>If you try invoking the program from the command line using the java command then it will have a console and the method should not return null.of that method will return null.</p> <p>Alternatively, using the Scanner class will work inside of your IDE:</p> <p><code>Scanner sc = new Scanner(System.in);</code></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload