Printing numbers with and without the + flag. - Java Language Basics

Java examples for Language Basics:Number Format

Description

Printing numbers with and without the + flag.

Demo Code

public class Main 
{
   public static void main(String[] args)
   { /* w ww . j  a va  2s  . c o  m*/
      System.out.printf("%d\t%d\n", 786, -786);
      System.out.printf("%+d\t%+d\n", 786, -786);
   } 
}

Result


Related Tutorials