Java DecimalFormat getNegativePrefix()方法

来源:这里教程网 时间:2026-02-17 20:45:42 作者:

Java DecimalFormat getNegativePrefix()方法

Java中 DecimalFormat 类的 getNegativePrefix() 方法用于获取该DecimalFormat实例的负前缀值。

语法:

public String getNegativePrefix()

参数 :该方法不接受任何参数。

返回值 :该方法返回该DecimalFormat实例的负前缀值。

下面的程序说明了上述方法。

// Java program to illustrate the// getNegativePrefix() method  import java.text.DecimalFormat;  public class GFG {      public static void main(String[] args)    {          // Create a DecimalFormat instance        DecimalFormat deciFormat = new DecimalFormat();          // Get the negative prefix value        String negativePrefix = deciFormat.getNegativePrefix();          System.out.println(negativePrefix);    }}

输出:

-

参考资料 : https://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html#getNegativePrefix()

相关推荐