Open In App

Bidi baseIsLeftToRight() method in Java with Examples

Last Updated : 19 Jan, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

The baseIsLeftToRight() method of java.text.Bidi class is used to check if this Bidi instance has left to right base direction or not. 

Syntax:

public boolean baseIsLeftToRight()

Parameter: This method accepts nothing as parameter.

 Return Value: This method return true if this bidi has left to right base direction otherwise false. 

Below are the examples to illustrate the baseIsLeftToRight() method: 

Example 1: 

Java




// 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");
    }
}


Output:

Base direction is left to right

Example 2: 

Java




// 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");
    }
}


Output:

Base direction is right to left

Reference: https://docs.oracle.com/javase/9/docs/api/java/text/Bidi.html#baseIsLeftToRight–



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads