+ 1

How to read data from keyboard for strings

I tried read more than two names from keyboard and I want to access those names again please can anyone explain me

1st Feb 2017, 5:58 PM
karishma
karishma - avatar
4 odpowiedzi
+ 1
Hi, you need to assign you input read to variables. Example: Scanner s = new Scanner(System.in); String name1= s.NextLine(); String name2= s.NextLine();
1st Feb 2017, 6:20 PM
Alex Soh Chye Wat
Alex Soh Chye Wat - avatar
+ 1
thanku and I have one doubt will we can do this using arrays concept
2nd Feb 2017, 2:55 AM
karishma
karishma - avatar
0
take Scanner class scan.next();
1st Feb 2017, 6:19 PM
Somnath Ghosh
Somnath Ghosh - avatar
0
just declare an array and use for loop to keep getting input from user until the size of array
2nd Feb 2017, 8:54 PM
Alex Soh Chye Wat
Alex Soh Chye Wat - avatar