Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Bidi getLength() method in Java with Examples

  • Last Updated : 03 Aug, 2021

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

Syntax:

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

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–




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!