當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。