0

My code doubt

How give user input through scanner in list with user size of list https://code.sololearn.com/cH7TF0QDslxZ/?ref=app

21st Jun 2020, 11:30 AM
Haritha Vuppula
Haritha Vuppula - avatar
3 Answers
+ 6
Haritha Vuppula everything is looking fine in your code try another plateform
21st Jun 2020, 5:03 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 3
Haritha Vuppula You can take input list like this Scanner sc = new Scanner(System.in); int num = sc.nextInt(); List<String> l = new ArrayList<String>(); for(int i = 0; i < num; i++) { l.add(sc.nextLine()); } Example: 5 // number of characters A B C D A
21st Jun 2020, 11:51 AM
A͢J
A͢J - avatar
+ 1
AJ Anant instead l.add(sc.nextLine()); in for loop i added l.add(i,sc.nextLine()); so my output came thnq😇
21st Jun 2020, 1:28 PM
Haritha Vuppula
Haritha Vuppula - avatar