Java String length()

 Posted On  | Yashwant Chavan 

In this tutorial you will learn how to get String length using java.

Refer below steps

  • String.length() method returns the length of this string.
  • For Unicode length is equal to the number of Unicode units in the string. Refer second example which prints length as 5.

Java String length example


public class StringLength {
    public static void main(String[] args) {
        String str = "technicalkeeda";
        System.out.println("World Length:- " + str.length());

        str = "\u0048\u0065\u006C\u006C\u006F";

        System.out.println("Unicode String " + str + " Length:- " + str.length());



World Length:- 14
Unicode String Hello Length:- 5

Promote your Blog, Website, or services on, My paypal id:

Payment will be accepted through paypal only.

© 2017

 |  Find us on Google+ |  Rss Feed

Loaded in 0.0303 seconds.