Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Bidi getBaseLevel() method in Java with Examples

  • Last Updated : 27 Nov, 2019

The getBaseLevel() method of java.text.Bidi class is used to get the base level of this instance of Bidi Class. Base level means whether this Bidi instance has base level “left to right” or “right to left”.

Syntax:

public int getBaseLevel()

Parameter: This method accepts nothing as parameter.

Return Value: This method used to provide 0 for left to right base level and 1 for right to left base level.

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

Example 1:




// Java program to demonstrate
// getBaseLevel() 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 base level
        // using getBaseLevel() method
        if (bidi.getBaseLevel())
            System.out.println("Base level is "
                               + "right to left");
        else
            System.out.println("Base level is "
                               + "left to right");
    }
}
Output:
Base level is right to left

Example 2:




// Java program to demonstrate
// getBaseLevel() 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_LEFT_TO_RIGHT);
  
        // getting base level
        // using getBaseLevel() method
        if (bidi.getBaseLevel())
            System.out.println("Base level is "
                               + "right to left");
        else
            System.out.println("Base level is "
                               + "left to right");
    }
}
Output:
Base level is left to right

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


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!