Java examples for Language Basics:Number Format
Printing numbers with and without the + flag.
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); } }