Bidi isLeftToRight() method in Java with Examples
Last Updated :
27 Nov, 2019
The isLeftToRight() method of java.text.Bidi class is used to check if it has left to right line and base direction both or not.
Syntax:
public boolean isLeftToRight()
Parameter: This method accepts nothing as parameter.
Return Value: This method return true if this bidi has both left to right line and base direction otherwise false.
Below are the examples to illustrate the isLeftToRight() 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" ,
Bidi.DIRECTION_LEFT_TO_RIGHT);
boolean status = bidi.isLeftToRight();
if (status)
System.out.println(
"Both Line and Base "
+ "direction is left to right" );
else
System.out.println(
"Both Line and Base "
+ "direction is not left to right " );
}
}
|
Output:
Both Line and Base direction is left to right
Example 2:
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" ,
Bidi.DIRECTION_RIGHT_TO_LEFT);
boolean status = bidi.isLeftToRight();
if (status)
System.out.println(
"Both Line and Base "
+ "direction is left to right" );
else
System.out.println(
"Both Line and Base "
+ "direction is not left to right " );
}
}
|
Output:
Both Line and Base direction is not left to right
Reference: https://docs.oracle.com/javase/9/docs/api/java/text/Bidi.html#isLeftToRight–
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...