5.11 Reading User Input

In this video, we will create a scanner object that will allow a user to write text. That is, the user, for example, will enter their name or age and the posters on the screen. As you can see, I’ve created a new project. So we come here and then we write Scanner (We have to make sure that the class was imported at the top). scanner = new Scanner (System.in) Scanner is therefore one of the built-in classes of Java and allows us to read user inputs. New (This word allows you to make a scanner instance, which means we create a new scanner object) Then we write, "Enter your name:" And we do String name = scanner.nextLine() Is left on hold until the user writes something. When the user writes and then presses Enter, the given number is assigned to the name variable So after closing the scanner (scanner.close() ) then executing the program