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


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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。