String length can be count with the help of length() method in java. length() method returns a value in integer. If string is having any character it will return integer in positive value, otherwise return 0 values. Use of String length() in java is shown below.
Example of String length() in java, JSP
public class StringLengthExample { public static void main(String[] args) { String string = "Count the String length"; int stringlength = string.length(); System.out.println("Total No of characters :"+stringlength); } }
Output
Total No of characters :23
Tags: String



Link to Us