当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


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-



相关用法


注:本文由纯净天空筛选整理自RohitPrasad3大神的英文原创作品 Bidi getRunStart() method in Java with Examples。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。