Sunday, February 22, 2026
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

1 COMMENT

Most Popular

Dominic
32506 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6882 POSTS0 COMMENTS
Nicole Veronica
12005 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12099 POSTS0 COMMENTS
Shaida Kate Naidoo
7011 POSTS0 COMMENTS
Ted Musemwa
7255 POSTS0 COMMENTS
Thapelo Manthata
6967 POSTS0 COMMENTS
Umr Jansen
6956 POSTS0 COMMENTS