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


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


java.text.Bidi類的getBaseLevel()方法用於獲取此Bidi類實例的基級。基本級別表示此Bidi實例具有基本級別“left to right”還是“right to left”。

用法:

public int getBaseLevel()

參數:此方法不接受任何參數。


返回值:此方法用於為左至右基礎級別提供0,為從右至左基礎級別提供1。

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

示例1:

// Java program to demonstrate 
// getBaseLevel() method 
  
import java.text.*; 
import java.util.*; 
import java.io.*; 
  
public class GFG { 
    public static void main(String[] argv) 
    { 
        // creating and initializing Bidi 
        Bidi bidi = new Bidi("Geeks for Geeks", 0); 
  
        // getting base level 
        // using getBaseLevel() method 
        if (bidi.getBaseLevel()) 
            System.out.println("Base level is "
                               + "right to left"); 
        else
            System.out.println("Base level is "
                               + "left to right"); 
    } 
}
輸出:
Base level is right to left

示例2:

// Java program to demonstrate 
// getBaseLevel() 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", 
                Bidi.DIRECTION_LEFT_TO_RIGHT); 
  
        // getting base level 
        // using getBaseLevel() method 
        if (bidi.getBaseLevel()) 
            System.out.println("Base level is "
                               + "right to left"); 
        else
            System.out.println("Base level is "
                               + "left to right"); 
    } 
}
輸出:
Base level is left to right

參考: https://docs.oracle.com/javase/9/docs/api/java/text/Bidi.html#getBaseLevel–



相關用法


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