About 50 results
Open links in new tab
  1. java.util.scanner - How can I read input from the console using the ...

    Here in this program we will take the Scanner class to achieve the task. This Scanner class comes under java.util, hence the first line of the program is import java.util.Scanner; which allows the user to …

  2. Instantiate Java Scanner in class or method - Stack Overflow

    Nov 24, 2014 · 2 this problem is so good,and i want to declare my opinion. on the one hand,in the model of Single-threaded ,the method of creating Scanner reference in class is equal to the method of …

  3. java - Getting Keyboard Input - Stack Overflow

    Jul 9, 2013 · It is the easiest way to read input in a Java program, though not very efficient. To create an object of Scanner class, we usually pass the predefined object System.in, which represents the …

  4. java - Utilizing a Scanner inside a method - Stack Overflow

    Apr 12, 2013 · I am using a scanner object for user input in a guess your number game. The scanner is declared in my main method, and will be used in a single other method (but that method will be …

  5. Reading a .txt file using Scanner class in Java - Stack Overflow

    java.io.FileNotFoundException: 10_Random (The system cannot find the file specified) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(Unknown Source) at …

  6. java - Placing object variables in scanner - Stack Overflow

    Apr 7, 2020 · Also I believe you must be coming from a javascript background based on the way you created the object. In Java , you need to create the object first before you can use it.

  7. java - What does Scanner input = new Scanner (System.in) actually …

    Jun 3, 2015 · Scanner s = new Scanner(System.in); Above statement creates an object of Scanner class which is defined in java.util.scanner package. Scanner class allows user to take input from …

  8. File and Scanner objects for opening and reading data in Java

    Aug 9, 2020 · Scanner inputFile = new Scanner("Customers.txt"); If Java needs a File object and a Scanner object, how is it exactly working behind?

  9. How can I clear the Scanner buffer in Java? - Stack Overflow

    May 15, 2012 · As comments point out, however, sometimes System.in input can be multi-line. You can instead create a new Scanner object where you want to clear the buffer if you are using System.in …

  10. Why do we need a Scanner Object for taking input in java

    Jul 8, 2017 · You should read the Scanner class' documentation. Scanner#nextInt() is a convenience method, you can easily read bytes from System.in without a Scanner object. Also, should the System …