Java中的 Bidi baseIsLeftToRight() 方法及示例
Java.text.Bidi类的baseIsLeftToRight()方法用于检查此Bidi 实例是否具有从左到右的基本方向。
句法:
public boolean baseIsLeftToRight()
参数:此方法不接受任何参数。
返回值:此方法返回true ,如果此bidi 具有从左到右的基本方向,否则返回false。
以下是说明getLength()方法的示例:
示例 1:
// Java program to demonstrate
// baseIsLeftToRight() method
import java.text.*;
import java.util.*;
import java.io.*;
public class GFG {
public static void main(String[] argv)
{
// creating and initializing Bidi
// with base direction
Bidi bidi
= new Bidi(
"Geeks For Geeks",
Bidi.DIRECTION_LEFT_TO_RIGHT);
// checking base direction
// using baseIsLeftToRight() method
boolean status
= bidi.baseIsLeftToRight();
// display the result
if (status)
System.out.println(
"Base direction is "
+ "left to right");
else
System.out.println(
"Base direction is "
+ "right to left");
}
}
输出:
Base direction is left to right
示例 2:
// Java program to demonstrate
// baseIsLeftToRight() method
import java.text.*;
import java.util.*;
import java.io.*;
public class GFG {
public static void main(String[] argv)
{
// creating and initializing Bidi
// with base direction
Bidi bidi
= new Bidi(
"Tajmahal",
Bidi.DIRECTION_RIGHT_TO_LEFT);
// checking base direction
// using baseIsLeftToRight() method
boolean status
= bidi.baseIsLeftToRight();
// display the result
if (status)
System.out.println(
"Base direction is "
+ "left to right");
else
System.out.println(
"Base direction is "
+ "right to left");
}
}
输出:
Base direction is right to left
参考: https://docs.oracle.com/javase/9/docs/api/ Java/text/Bidi.html#baseIsLeftToRight–