+ 1
Java console class
Recently I had a look at the java console class and I saw that System.console() has a possibility of returning null. In what case does this occur in? and what is the main use of the console class in java?
2 RĂ©ponses
+ 2
Console is a class in java.io.Console. It is used to read input like Scanner. You can get a line of input with Console.console().readLine().
Console class is a singleton. Meaning that it has only 1 object, which can be accessed with console() method.
console() returns the only object of Console class. If Console somehow doesn't have an object, it returns null.
0
CarrieForle Thank you for the answer