Home Jsp Simple-jsp-example String Length
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

String Length

Advertisement
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.

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 11, 2008

Related Tutorials

Ask Questions?    Discuss: String Length   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com