0

methods to enter input in java....??

system.out.println is used for output...how we enter input ???

5th Feb 2017, 4:13 PM
sagar
sagar - avatar
5 Answers
+ 5
//First import scanner: import java.util.Scanner; //then make an instance of it: Scanner cin = new Scanner(System.in); //then use it to get user input : String text = cin.nextLine();
5th Feb 2017, 4:20 PM
Alireza M
Alireza M - avatar
0
Hi, there is the Scanner class for input. You have to create an object: Scanner input = new Scanner(System.in); then you can use it like this: String var = input.NextLine();
5th Feb 2017, 4:18 PM
Edi Lipovac
Edi Lipovac - avatar
0
U can also use the Buffered Reader object. Ask me if u wanna know.
6th Feb 2017, 2:10 PM
Bhaskar M R
Bhaskar M R - avatar
0
thnkuu all of you....uhh helped me alot
11th Jul 2017, 5:34 AM
sagar
sagar - avatar
- 1
The last code line the posters above answered "String var = input.NextLine(); "depends on the varibale eg if its double, it will be =input.nextDouble and so on
15th Feb 2017, 7:12 AM
Tochukwu
Tochukwu - avatar