+ 1

Text input in java

I have been taking notes and I remember that I've seen it done but I can't remember or find how to make a text input for a variable.

22nd Jun 2017, 8:40 PM
Kenneth Sorrells
Kenneth Sorrells - avatar
4 Answers
+ 12
If you mean String, then use the following way: Scanner input = new Scanner (System.in); String message = input.nextLine();
22nd Jun 2017, 8:47 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 6
import java.util.Scanner; public class Test{ public static void main(String args[]){ String Text; Scanner stdin = new Scanner(System.in); Text= stdin.nextLine(); System.out.println(Text); } }
22nd Jun 2017, 9:03 PM
Yasiru Nayanajith
Yasiru Nayanajith - avatar
+ 2
import scanner then write the following code Scanner s =new Scanner(System.in); String a=s.nextLine();
23rd Jun 2017, 5:03 PM
Vishesh
0
import java.util.Scanner Then, Scanner variable = new Scanner(System.in); int variable_name=variable.nextInt(); double variable_name=variable.nextDouble(); String variable_name=variable.nextLine();
25th Jun 2017, 5:15 AM
Md Riad Hasan Sarker
Md Riad Hasan Sarker - avatar