. Advertisement .
..3..
. Advertisement .
..4..
How To Store User Input In Java? I have found some ways but it’s quite troublesome. If anyone has a simple solution please let me know. Thank you!
Method 1: Use BufferedReader
For example:
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = br.readLine(); // read line
int c = br.read(); // read single char
Method 2: Follow these steps:
Scanner sc = new Scanner(System.in);
String s = sc.next();
int n = sc.nextInt();
double d = sc.nextDouble();
float f = sc.nextFloat();
Here is the instruction that worked for me, Let’s check it out.