Saturday, November 22, 2025
HomeLanguagesJavaBidi getLength() method in Java with Examples

Bidi getLength() method in Java with Examples

The getLength() method of java.text.Bidi class is used to get the length of the text in this Bidi instance.

Syntax:

public int getLength()

Parameter: This method accepts nothing as parameter.

Return Value: This method provides the length of the bidi text as integer.

Below are the examples to illustrate the getLength() method:

Example 1:




// Java program to demonstrate
// getLength() method
  
import java.text.*;
import java.util.*;
import java.io.*;
  
public class GFG {
    public static void main(String[] argv)
    {
        // creating and initializing Bidi
        Bidi bidi
            = new Bidi("Geeks For Geeks", 0);
  
        // getting the length of line of text
        // using getLength() method
        int length = bidi.getLength();
  
        // display the result
        System.out.println("length of line : "
                           + length);
    }
}


Output:

length of line : 15

Example 2:




// Java program to demonstrate
// getLength() method
  
import java.text.*;
import java.util.*;
import java.io.*;
  
public class GFG {
    public static void main(String[] argv)
    {
        // creating and initializing Bidi
        Bidi bidi = new Bidi("Tajmahal", 0);
  
        // getting the length of line of text
        // using getLength() method
        int length = bidi.getLength();
  
        // display the result
        System.out.println("length of line : "
                           + length);
    }
}


Output:

length of line : 8

Reference: https://docs.oracle.com/javase/9/docs/api/java/text/Bidi.html#getLength–

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32407 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6785 POSTS0 COMMENTS
Nicole Veronica
11932 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12000 POSTS0 COMMENTS
Shaida Kate Naidoo
6907 POSTS0 COMMENTS
Ted Musemwa
7168 POSTS0 COMMENTS
Thapelo Manthata
6864 POSTS0 COMMENTS
Umr Jansen
6852 POSTS0 COMMENTS