About 361,000 results
Open links in new tab
  1. How to get the user input in Java? - Stack Overflow

    May 19, 2020 · The best two options are BufferedReader and Scanner.. The most widely used method is Scanner and I personally prefer it because of its simplicity and easy implementation, as well as its powerful utility to parse text into primitive data.

  2. Java Scanner String input - Stack Overflow

    Mar 22, 2012 · If you use the nextLine() method immediately following the nextInt() method, nextInt() reads integer tokens; because of this, the last newline character for that line of integer input is still queued in the input buffer and the next nextLine() will be reading the remainder of the integer line (which is empty).

  3. String input in java - Stack Overflow

    Apr 30, 2015 · nextLine() reads everything up to and including the next newline character. However, nextInt() only reads the characters that make up the integer, and if the integer is the last (or only) text in the line, you'll be left with only the newline character.

  4. Getting string from input in Java - Stack Overflow

    Mar 29, 2014 · I am a newbie to Java, and I'm trying to get a string from an input with multiple lines. e.g. a string ="The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick fox jumps over the lazy dog. " from the input, like this: The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the ...

  5. java - Getting Keyboard Input - Stack Overflow

    Jul 9, 2013 · In java we can read input values in 6 ways: Scanner Class; BufferedReader; Console class; Command line; AWT, String, GUI; System properties; Scanner class: present in java.util.*; package and it has many methods, based your input types you can utilize those methods. a.

  6. How to take input as String with spaces in java using scanner

    Sep 15, 2016 · One can use the delimiter function to segregate your input as shown below. import java.util.Scanner ...

  7. java - User input stored in a String array - Stack Overflow

    Since you know that you want to have an array of 20 string: String[] array = new String[20]; Then your for loop should use the length of the array to determine when the loop should stop. Also you loop is missing an incrementer. Try the following code to get you going:

  8. How to read integer value from the standard input in Java

    May 2, 2010 · The question is "How to read from standard input". A console is a device typically associated to the keyboard and display from which a program is launched. You may wish to test if no Java console device is available, e.g. Java VM not started from a command line or the standard input and output streams are redirected.

  9. Java: How to get input from System.console() - Stack Overflow

    Jan 10, 2011 · Use new java.io.IO class previewed in Java 24. String input = IO.readln ( "Enter text: " ); Caveat: This Answer is based on a preview feature which may change or be cancelled. System.console does work. Calling System.console() from the IntelliJ IDE does work for me.

  10. java - How to get a string from input box? - Stack Overflow

    Feb 3, 2019 · It is quite straight forward. See below minimal example. When user enters some text in the text field and clicks "OK" button, showInputDialog() method returns that text entered by the user.

Refresh