Sunday, December 14, 2025
HomeLanguagesJavaBidi getRunLevel() method in Java with Examples

Bidi getRunLevel() method in Java with Examples

The getRunLevel() method of java.text.Bidi class used to provide the level for the nth run of this line of text if there is only one running state then It will provide base level for that state . Syntax:

public int getRunLevel(int run)

Parameters: This method accepts the index of the logical run for which the level of the run is to be retrieved. Return Value: This method provides the level for the particular run in the line of text. Below are the examples to illustrate the getRunLevel() method: Example 1: 

Java




// Java program to demonstrate
// getRunLevel() 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",
                Bidi.DIRECTION_RIGHT_TO_LEFT);
 
        // index for which level is needed
        int index = 0;
 
        // getting the level of run
        // using getRunLevel() method
        int level = bidi.getRunLevel(index);
 
        // display the result
        System.out.println(
            "level of first run is : "
            + level);
    }
}


Output:

level of first run is : 2

Example 2: 

Java




// Java program to demonstrate
// getRunLevel() 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",
                Bidi.DIRECTION_LEFT_TO_RIGHT);
 
        // index for which level is needed
        int index = 0;
 
        // getting the level of run
        // using getRunLevel() method
        int level = bidi.getRunLevel(index);
 
        // display the result
        System.out.println(
            "level of first run is : "
            + level);
    }
}


Output:

level of first run is : 0

Reference: https://docs.oracle.com/javase/9/docs/api/java/text/Bidi.html#getRunLevel-int-

RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32447 POSTS0 COMMENTS
Milvus
105 POSTS0 COMMENTS
Nango Kala
6816 POSTS0 COMMENTS
Nicole Veronica
11953 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12031 POSTS0 COMMENTS
Shaida Kate Naidoo
6951 POSTS0 COMMENTS
Ted Musemwa
7202 POSTS0 COMMENTS
Thapelo Manthata
6898 POSTS0 COMMENTS
Umr Jansen
6882 POSTS0 COMMENTS