So in my AP Computer science class, we are starting to work on array lists. I was hoping that somebody here would be able to help me with taking user input from a scan.nextLine command and puting it into an array list. The second problem that i have is recognizing a string that is input and stop the scan.nextLine when that input is recognized.
Much appreciated,
-Sektess
That’s a rather basic question, not a an advanced one and I’m afraid you are mistaking this forum with some generalist Q&A site such as StackOverflow. This place is primarily dedicated to address very complex problems in the field of artificial intelligence and provide answers to fundamental questions, mainly revolving about knowing why Thor keeps falling of the cliff at position (18, 17).
Well… why? I had a short MP exchange with @CvxFous couple weeks ago regarding this question, and it doesn’t seem wrong to also have general questions on a language. This seems to map well with the vision the CiG team has of the sie aniway: a platform where one could also learn and discuss new languages. Without the possibility to discuss those language in a more “generic” way, this might be hard
That being said, StackOverflow will always be a natural choice, as the community is huge!
Back to the original question, how about something like:
List<String> list = new ArrayList<>();
list.add(scan.nextLine());
by the way, this is (kind of) the first google result to your qustion. Have you tried it?
Well, Marvel Entertainment made Thor be a Frog and a Horse. CodinGame can make him be a lemming
Hi,
you can try this :
List<String> result = Stream
.generate(in::nextLine)
.limit(numberOfEntryYouWouldRead)
.collect(Collectors.toList());
Cool. Thank you all for your help