Sunday, October 5, 2025
HomeLanguagesJavaBidi getRunCount() method in Java with Examples

Bidi getRunCount() method in Java with Examples

The getRunCount() method of java.security.Bidi class used to provide the number of base levels present in line of bidi text. Here we will find only one base level because we are using only one base level at a time.

Syntax:

public int getRunCount()

Parameter: This method accepts nothing as parameter.

Return Value: This method provides the number of levels currently running .

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

Example 1:




// Java program to demonstrate
// getRunCount() 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);
  
        // getting the number of level
        // using getRunCount() method
        int lvl = bidi.getRunCount();
  
        // display the result
        System.out.println(
            "number of levels : "
            + lvl);
    }
}


Output:

number of levels : 1

Example 2:




// Java program to demonstrate
// getRunCount() 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);
  
        // getting the number of level
        // using getRunCount() method
        int lvl = bidi.getRunCount();
  
        // display the result
        System.out.println(
            "number of levels : "
            + lvl);
    }
}


Output:

number of levels : 1

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

RELATED ARTICLES

Most Popular

Dominic
32337 POSTS0 COMMENTS
Milvus
86 POSTS0 COMMENTS
Nango Kala
6706 POSTS0 COMMENTS
Nicole Veronica
11871 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11934 POSTS0 COMMENTS
Shaida Kate Naidoo
6821 POSTS0 COMMENTS
Ted Musemwa
7087 POSTS0 COMMENTS
Thapelo Manthata
6779 POSTS0 COMMENTS
Umr Jansen
6778 POSTS0 COMMENTS