0

How to take user input?

In the 'Exceptions, Lists, Files and Threads' lessons of java, how do you take user input? ArrayList, LinkedList, Hashmaps and Iterators doesn't show how to take user inp but instead the elements are added by put method. Or is it added by taking the user input first using scanner and then implemented into them? If so, how?

26th Dec 2020, 7:24 PM
Mayur Gowda
Mayur Gowda - avatar
3 Antworten
+ 3
Yes. Fisrt take input by scanner object and then add it List by add method. If inp is Scanner object then read string by String s=inp.next(); Next add by add method if Al is ArrayList object then as Al.add(s); You can combine also as Al.add(inp.next()) ;
26th Dec 2020, 7:44 PM
Jayakrishna 🇮🇳
+ 2
You're welcome..
26th Dec 2020, 7:54 PM
Jayakrishna 🇮🇳
+ 1
26th Dec 2020, 7:54 PM
Mayur Gowda
Mayur Gowda - avatar