java.text.Bidi类的getLength()方法用于获取此Bidi实例中文本的长度。
用法:
public int getLength()
参数:此方法不接受任何参数。
返回值:此方法将bidi文本的长度提供为整数。
下面是说明getLength()方法的示例:
示例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 lenght = bidi.getLength();
// display the result
System.out.println("lenght of line : "
+ lenght);
}
}
输出:
lenght of line : 15
示例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 lenght = bidi.getLength();
// display the result
System.out.println("lenght of line : "
+ lenght);
}
}
输出:
lenght of line : 8