Open In App

Bidi getLength() method in Java with Examples

Last Updated : 03 Aug, 2021
Comments
Improve
Suggest changes
Like Article
Like
Report
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
// 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
// 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--

Next Article
Practice Tags :

Similar Reads