+ 7
Does anyone know how to iterate over several input strings through Scanner in java, and play with each string in the given line
for example Input : This That There, if I would Have to change char sequence of each word, how can I make the scanner process each word seperately
6 ответов
+ 7
Mirielle🐶 [Inactive] Also,when I tried it with a do{
input. next()
} while(input. hasNext()) ;, It worked like a gem, and processed every single string subsequently in the sentence with the given code, Thanks Again
+ 6
Mirielle🐶 [Inactive] Thanks mirielle, looks like hasNext method was all I was looking for, Thanks for telling that with a while loop 😃😃😃😄🌹
+ 5
~ swim ~ I've worked with scanner alot, but still can't say i thoroughly understand it when it comes to strings yet.
+ 5
Jayakrishna thanks for this, but I was looking for a subtly more sophistocated method, as I wanted to process 'each' word with the given single input
+ 2
Are you looking to "split" (that's a clue) the input into individual elements/words?
+ 1
Scanner is used to take only input values. so for taking input,
If "scan" is scanner object,
then use like. :
scan.next() // accept a word.
scan.nextLine() // accept total line as input..
After taking input, hoping you can do your remaining tasks.. Is it what you need?