Using the (flag to place parentheses around negative numbers. - Java Language Basics

Java examples for Language Basics:Number Format

Description

Using the (flag to place parentheses around negative numbers.

Demo Code

public class Main 
{
   public static void main(String[] args) 
   {// w  ww.ja  v  a 2  s  . c  o m
      System.out.printf("%(d\n", 50);
      System.out.printf("%(d\n", -50);
      System.out.printf("%(.1e\n", -50.0);
   } 
}

Result


Related Tutorials