java.text.ChoiceFormat類的getLimits()方法用於在初始化時獲取選擇格式對象的附加限製。它返回帶有限製的double類型數組。
用法:
public double[] getLimits()
參數:此方法不接受任何參數。
返回值:此方法返回附加到選擇格式對象的限製。
下麵是說明getLimits()方法的示例:
示例1:
// Java program to demonstrate getLimits() method
import java.text.*;
import java.util.*;
import java.io.*;
public class GFG {
public static void main(String[] argv)
{
// creating and initializing ChoiceFormat
ChoiceFormat cf
= new ChoiceFormat(
"4#wed| 5#thu | 6#fri | 7#sat");
// getting limit attached to the ChoiceFormat
// using getLimits() method
double[] format = cf.getLimits();
// display the result
System.out.print("Limit: "
+ Arrays.toString(format));
}
}
輸出:
Limit: [4.0, 5.0, 6.0, 7.0]
示例2:
// Java program to demonstrate getLimits() method
import java.text.*;
import java.util.*;
import java.io.*;
public class GFG {
public static void main(String[] argv)
{
// creating and initializing limit
double[] limit = { 1, 2, 3, 4 };
// creating and initializing format
String[] format
= { "add", "sub", "multiply", "divide" };
// creating and initializing ChoiceFormat
ChoiceFormat cf
= new ChoiceFormat(limit, format);
// getting limit attached to the ChoiceFormat
// using getLimits() method
double[] forma = cf.getLimits();
// display the result
System.out.print("Limit: "
+ Arrays.toString(format));
}
}
輸出:
Limit: [add, sub, multiply, divide]
參考: https://docs.oracle.com/javase/9/docs/api/java/text/ChoiceFormat.html#getLimits–
相關用法
- Java ChoiceFormat hashCode()用法及代碼示例
- Java ChoiceFormat getFormats()用法及代碼示例
- Java ChoiceFormat previousDouble()用法及代碼示例
- Java ChoiceFormat parse()用法及代碼示例
- Java ChoiceFormat setChoices()用法及代碼示例
- Java ChoiceFormat format()用法及代碼示例
- Java ChoiceFormat equals()用法及代碼示例
- Java ChoiceFormat applyPattern()用法及代碼示例
- Java ChoiceFormat nextDouble(double)用法及代碼示例
- Java ChoiceFormat nextDouble(double, boolean)用法及代碼示例
- Java Java lang.Long.reverse()用法及代碼示例
- Java Java lang.Long.builtcount()用法及代碼示例
- Java Java lang.Long.byteValue()用法及代碼示例
- Java Java.util.Collections.disjoint()用法及代碼示例
注:本文由純淨天空篩選整理自RohitPrasad3大神的英文原創作品 ChoiceFormat getLimits() method in Java with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。