Word counter Program In Java -


while creating word counter in java through collecting user input scanner i've been running error of having program display there 1 word entered when there space entered in after final word in char. there way check user input space , remove before entering word count loop?

right after...

string userinput = wordcounter.nextline(); 

... add line:

userinput = userinput.trim(); 

it should fix problem, since function trim() gets rid of blank spaces @ beginning or ending of string.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -