Java NumberFormat getIntegerInstance()方法及示例
- getIntegerInstance()方法是java.text.NumberFormat的一个内置方法,用于返回当前默认FORMAT区域的整数格式。
语法 :
参数 :该函数不接受任何参数。
返回值 :该函数返回NumberFormat实例,用于对整数值进行通用格式化。
下面是上述函数的实现。
程序 1:
输出:
程序 2:
输出:
参考: https://docs.oracle.com/javase/10/docs/api/java/text/NumberFormat.html#getIntegerInstance()
- getIntegerIntegerInstance(Locale inLocale)方法是java.text.NumberFormat的一个内置方法,它为任何指定的locale返回一个整数的数字格式。
语法 :
public static NumberFormat getIntegerInstance(Locale inLocale)
参数 : 该函数接受一个强制性参数inLocale,描述要指定的语言。
返回值 : 该函数返回NumberFormat实例,用于对整数值进行格式化。
下面是上述函数的实现。
程序 1:
输出:
参考: https://docs.oracle.com/javase/10/docs/api/java/text/NumberFormat.html#getIntegerInstance(java.util.Locale)