Home Jsp Simple-jsp-example String Length



String Length
Posted on: March 11, 2008 at 12:00 AM
In java, Strings are objects that belong to class java.lang.String. A string is a sequence of simple characters.

String Length

        

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:

Download this example.

Related Tags for String Length:
javacstringcomclassstringsobjectobjectsfindcharcomparesequencelengthcharactersimplecharacterslikelongctewithconcatenatenattolaneitcanliimmanceinconcatasmoutpartrthincajclobjcatdosatanyrackishamplaractstrsimvaseqssriringthavbelosthatseqctsfinmanyjepleplndonomo


More Tutorials from this section

Ask Questions?    Discuss: String Length   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

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.