Total number of characters in the String with Example : Java Program Code

The number of characters in the string can be calculated  using array in java .
It is very useful when we want to restrict the number of characters for a particular field in the UI.
for example :
we want that the first name of user should not exceed 20 characters , so , to check that validation we need to calculate the number of characters in the user input .
if user inputs like 
"Alive is awesome"
then the number of characters in it is : 14



Demo :


count number of characters in java program















About The Author

Subham Mittal has worked in Oracle for 3 years.
Enjoyed this post? Never miss out on future posts by subscribing JavaHungry