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?
3 Respuestas
+ 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()) ;
+ 2
You're welcome..
+ 1
Ok, Thanks Jayakrishna🇮🇳