Java - Word length
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?
Assuming you've read the word into a String variable, you can use the .length() method:
Hope that helps,
Twilight Dragon
String word;// read in the wordint numchars = word.length();
Hope that helps,
Twilight Dragon
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement