Scanner in = new Scanner(System.in); int N = in.nextInt(); 

As I understand it, the first line creates an in instance of the Scanner class (the default constructor is used). And in the second integer variable N using the nextInt() method, which reads the first number entered from the keyboard, the value we entered is assigned. Did I understand this correctly? And what in the first case does the entry in brackets in the first line mean?

    1 answer 1

    The nextInt() method reads an integer value from the input stream. In this case, this value is stored in the variable N

    And what in the first case does the entry in brackets in the first line mean?

    To create a Scanner object, you must specify for which particular input stream it is created.

     Scanner in = new Scanner(System.in); 

    In this particular case, a Scanner object is created for the standard input stream (keyboard).

    • Thanks, got it. - Muscled Boy