Java - Word length

Started by
1 comment, last by xDMG89x 18 years, 8 months ago
How do you count the number of characters in a word that is inputted by the user in Java? Is there a command or function that will return the number of characters?
Advertisement
Assuming you've read the word into a String variable, you can use the .length() method:
String word;// read in the wordint numchars = word.length();


Hope that helps,
Twilight Dragon
{[JohnE, Chief Architect and Senior Programmer, Twilight Dragon Media{[+++{GCC/MinGW}+++{Code::Blocks IDE}+++{wxWidgets Cross-Platform Native UI Framework}+++
Ahh, thank you very much that worked out perfectly ;).

This topic is closed to new replies.

Advertisement