Open In App

Bidi isLeftToRight() method in Java with Examples

Improve
Improve
Like Article
Like
Save
Share
Report

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:




// Java program to demonstrate
// isLeftToRight() 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 both line and base direction
        // using isLeftToRight() method
        boolean status = bidi.isLeftToRight();
  
        // display the result
        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:




// Java program to demonstrate
// isLeftToRight() 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_RIGHT_TO_LEFT);
  
        // checking both line and base direction
        // using isLeftToRight() method
        boolean status = bidi.isLeftToRight();
  
        // display the result
        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–



Last Updated : 27 Nov, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads