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


Java Bidi createLineBidi()用法及代碼示例


java.text.Bidi類的createLineBidi()方法用於創建具有相同基本方向並表示該範圍內當前bidi的每個屬性的新的bidi對象。

用法:

public Bidi createLineBidi(int lineStart,
                           int lineLimit)

參數:此方法將以下參數作為參數


  • lineStart:這是這個新比迪煙的起點
  • lineLimit:這是此新比迪煙的終點

返回值:此方法返回一個新的Bidi對象

下麵是說明createLineBidi()方法的示例:

示例1:

// Java program to demonstrate 
// createLineBidi() method 
  
import java.text.*; 
import java.util.*; 
import java.io.*; 
  
public class GFG { 
    public static void main(String[] argv) 
    { 
        // creating and initializing Bidi 
        // text with base direction 
        Bidi bidi 
            = new Bidi( 
                "Geeks For Geeks", 
                Bidi.DIRECTION_RIGHT_TO_LEFT); 
  
        // creating and new bidi Object using the old one 
        // using createLineBidi() method 
        Bidi newbidi = bidi.createLineBidi(1, 6); 
  
        // display the new bidi status 
        System.out.println("New Bidi "
                           + "\nLength : "
                           + newbidi.getLength() 
                           + "\nnumber of levels : "
                           + newbidi.getRunCount() 
                           + "\nBase Level : "
                           + newbidi.getBaseLevel()); 
    } 
}
輸出:
New Bidi 
Length : 5
number of levels : 2
Base Level : 1

示例2:

// Java program to demonstrate 
// createLineBidi() method 
  
import java.text.*; 
import java.util.*; 
import java.io.*; 
  
public class GFG { 
    public static void main(String[] argv) 
    { 
        // creating and initializing Bidi 
        // text with base direction 
        Bidi bidi 
            = new Bidi("Tajmahal", 
                       Bidi.DIRECTION_RIGHT_TO_LEFT); 
  
        // creating and new bidi Object using the old one 
        // using createLineBidi() method 
        Bidi newbidi = bidi.createLineBidi(3, 5); 
  
        // display the new bidi status 
        System.out.println("New Bidi "
                           + "\nLength : "
                           + newbidi.getLength() 
                           + "\nnumber of levels : "
                           + newbidi.getRunCount() 
                           + "\nBase Level : "
                           + newbidi.getBaseLevel()); 
    } 
}
輸出:
New Bidi 
Length : 2
number of levels : 1
Base Level : 2

參考: https://docs.oracle.com/javase/9/docs/api/java/text/Bidi.html#createLineBidi-int-int-



相關用法


注:本文由純淨天空篩選整理自RohitPrasad3大神的英文原創作品 Bidi createLineBidi() method in Java with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。