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:
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:
import java.text.*;
import java.util.*;
import java.io.*;
public class GFG {
public static void main(String[] argv)
{
Bidi bidi
= new Bidi( "Geeks For Geeks" , 0 );
int length = bidi.getLength();
System.out.println( "length of line : "
+ length);
}
}
|
Output:
length of line : 15
Example 2:
import java.text.*;
import java.util.*;
import java.io.*;
public class GFG {
public static void main(String[] argv)
{
Bidi bidi = new Bidi( "Tajmahal" , 0 );
int length = bidi.getLength();
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–
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...