+ 1
How to get input from the keyboard to the variable
7 Answers
+ 3
import java.util.Scanner;
public class Anything{
public static void main(String[] args){
Scanner anyOtherThing = new Scanner(System.in);
String input=anyOtherThing.next();
}}
Hence input has required input (LOL)
ALSO, if you want an integer input, replace last line by,
int input=anyOtherName.nextInt();
if its double then nextDouble();. etc...
+ 1
use scanner or bufferReader
0
When using this syntax it throws an error that scanner cannot be resolved to a type
0
change next() to nextLine();
0
still the same error appears
0
make sure, you have imported Scanner class.
0
Its working absolutely fine by me.
Please re-do it in Soloearn's code Playground and save it ,make it public and msg me. I will check it.