About 14,800,000 results
Open links in new tab
  1. Java User Input (Scanner class) - W3Schools

    The Scanner class is used to get user input, and it is found in the java.util package. To use the Scanner class, create an object of the class and use any of the available methods found in the Scanner class documentation.

  2. Java Scanner String input - Stack Overflow

    Mar 22, 2012 · I'm writing a program that uses an Event class, which has in it an instance of a calendar, and a description of type String. The method to create an event uses a Scanner to take in a month, day, year, hour, minute, and a description. The problem I'm having is that the Scanner.next() method only returns the first word before a space.

  3. How to read strings from a Scanner in a Java console application?

    Jul 17, 2013 · What you can do is use delimeter as new line. Till you press enter key you will be able to read it as string. Scanner sc = new Scanner(System.in); sc.useDelimiter(System.getProperty("line.separator")); Hope this helps.

  4. Java User Input – Scanner Class - GeeksforGeeks

    Apr 22, 2025 · Import the Scanner class using import java.util.Scanner;; Create the Scanner object and connect Scanner with System.in by passing it as an argument i.e., Scanner sc = new Scanner(System.in);; When we want to ask the user for input, first print a prompt message so they know what to enter. Then use one of Scanner’s handy methods to read the response:

  5. Java Scanner String input example - TheServerSide

    Jul 23, 2022 · Java’s Scanner String input method. To take String input from the user with Java’s Scanner class, just follow these steps. Import java.util.*; to make Java’s Scanner class available; Use the new keyword to create an instance of the Scanner class; Pass the static System.in object to the Scanner’s Java constructor

  6. Read user input using the Scanner class - JAVAHANDSON

    Nov 27, 2023 · In this article, we will learn what is a Scanner class and how to read user input using the Scanner class with proper examples.

  7. Java Scanner (With Examples) - Programiz

    The Scanner class of the java.util package is used to read input data from different sources like input streams, users, files, etc. In this tutorial, we will learn about the Java Scanner and its methods with the help of examples.

  8. Beginner's Guide To Java Scanner (With Code Examples)

    public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Enter your name: "); String name = scanner.nextLine(); System.out.println("Hello, " + name + "!"); When this program runs, it will pause and wait for the user to type their name.

  9. How to Use the Java Scanner Class to Read Strings

    The Java Scanner class is a powerful tool for capturing user input, including strings, from various sources such as keyboard input or files. This guide provides a comprehensive breakdown of how to effectively use the Scanner class to read strings from user input in Java applications.

  10. Java Scanner - Java Guides

    The Scanner class in Java, part of the java.util package, is a utility class used to parse primitive types and strings using regular expressions. It can read input from various sources, including strings, files, and input streams. The Scanner class is widely used for reading user input in console applications. Table of Contents. What is the ...

Refresh