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 :
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 :