📜  Java中的 Bidi getRunStart() 方法和示例

📅  最后修改于: 2022-05-13 01:55:05.795000             🧑  作者: Mango

Java中的 Bidi getRunStart() 方法和示例

Java.text.Bidi类的getRunStart()方法用于提供此 Bidi 实例第 n 次运行开始的第一个字符的索引。

句法:

public int getRunStart(int run)

参数:此方法接受要为其检索运行开始的逻辑运行的索引

返回值:此方法提供第 n 次逻辑运行的起始字符索引

以下是说明getRunStart()方法的示例:

示例 1:

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

示例 2:

// Java program to demonstrate
// getRunStart() 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", 1);
  
        int index = 0;
  
        // getting the start of run for the index 0
        // using getRunStart() method
        int level = bidi.getRunStart(index);
  
        // display the result
        System.out.println(
            "start of run for index 0 is : "
            + level);
    }
}
输出:
start of run for index 0 is : 0

参考: https://docs.oracle.com/javase/9/docs/api/ Java/text/Bidi.html#getRunStart-int-