In java, Strings are objects that belong to class java.lang.String. A string is a sequence of simple characters. We can do many things with the string object like we can find out its length, we can compare it with other string, concatenate with other string.
We can get the length of the string by using the method length() of java.lang.String.
The code of the program is given below:
<html>
<head>
<title>Getting Length of a String</title>
</head>
<body>
<h1>Getting Length of a String</h1>
<%
String s1 = "Length of a String!";
out.println("\"" + s1 + "\"" + " is of " +
s1.length() + " characters ");
%>
</body>
</html>
|
The output of the program is given below:

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: String Length View All Comments
Post your Comment