As we're using Intellij idea for development, the example provided in Activity 1 of section Variables, Data Types and Operators is failing with error:
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.io.Console.readLine()" because "console" is null at VariablesDataTypesOperators.MyFirstInput.main(MyFirstInput.java:9)
Reason for error:
The System.console() method returns a Console object if the JVM is started from a console and not from an IDE or a non-interactive environment. In an IDE or certain execution environments, this method may return null
Proposed solustion:
If you want your code to work in a variety of environments, including IDEs, you should consider using the Scanner class or another input method that is not dependent on the availability of a console object.