📌  相关文章
📜  Java中的 DecimalFormat setNegativeSuffix() 方法

📅  最后修改于: 2022-05-13 01:55:19.397000             🧑  作者: Mango

Java中的 DecimalFormat setNegativeSuffix() 方法

Java中DecimalFormat类的setNegativeSuffix()方法用于为这个DecimalFormat实例设置一个负后缀值。

语法

public void setNegativeSuffix(String newValue)

参数:此方法的单个参数newValue是要设置为此 DecimalFormat 实例的负后缀的新值。

返回值:此方法不返回任何值。

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

// Java program to illustrate the
// setNegativeSuffix() method
  
import java.text.DecimalFormat;
  
public class GFG {
  
    public static void main(String[] args)
    {
  
        // Create a DecimalFormat instance
        DecimalFormat deciFormat = new DecimalFormat();
  
        // Set a negative suffix value
        deciFormat.setNegativeSuffix("negative");
  
        // Print a number with negative suffix
        System.out.println(deciFormat.format(-123.45));
    }
}
输出:
-123.45negative

参考:https: Java Java.lang.String)