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
Post a Comment