0
My code doubt
How give user input through scanner in list with user size of list https://code.sololearn.com/cH7TF0QDslxZ/?ref=app
3 Answers
+ 6
Haritha Vuppula everything is looking fine in your code try another plateform
+ 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
+ 1
AJ Anant
instead l.add(sc.nextLine()); in for loop
i added l.add(i,sc.nextLine());
so my output came thnqđ