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

    To access methods in the Scanner class create a new scanner object as "in". Now we use one of its method, that is "next". The "next" method gets the string of text that a user enters on the …

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

    I am working on a Java program that reads a text file line-by-line, each with a number, takes each number throws it into an array, then tries and use insertion sort to sort the array. I need help w...

  3. java - Take a char input from the Scanner - Stack Overflow

    Dec 19, 2012 · There are three ways to approach this problem: Call next() on the Scanner, and extract the first character of the String (e.g. charAt(0)) If you want to read the rest of the line as …

  4. java - How to put a Scanner input into an array... for example a …

    Jul 10, 2018 · import java.util.Scanner; import java.util.ArrayList; public class Main { public static void main (String ...

  5. java - How to make a ONE static scanner global variable without …

    I want to create a static scanner but i will like to put the try catch block around it so it can automatically close avoiding resources leaks and or this exception: Exception in thread "main" …

  6. java - Make a Scanner object declared in main() accessible in all ...

    I tried to declare a new Scanner object. It works fine in the main() method, but in the other methods it is not accessible. import java.util.Scanner; public class Exe1GenericSort { public sta...

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

    Apr 12, 2013 · Passing the scanner to the DataTest method, or; Making the scanner static in the class. Here is how you can pass the scanner: public static int DataTest(int selectionBound, …

  8. How do I set up a scanner object in Java? - Stack Overflow

    Oct 1, 2015 · I'm trying to write a program that will read in a file of students academic credit data and create a list of students on academic warning. I first need to set up a Scanner object to …

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

    Nov 24, 2014 · To create a Scanner reference in a class & instantiate it -> use it in each method private Scanner sc = new Scanner(System.in); public int readInt() { int input = sc.nextInt(); // …

  10. java - Creating object from scanner input - Stack Overflow

    May 7, 2025 · Create only one Scanner object java. 0. Java input/output and Scanner object. 0. Is it possible to use a ...