How to Find Length of a String in Java


In this example we will show the method to find the length of a string in Java.

Source Code

package com.beginner.examples;

public class StringLength {
  public static void main(String[] args) {
    String str = "36n8cbwqb";
    System.out.println(str.length()); // get the length of a string
  }
}

Output:

9
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments