Using floating-point conversion characters. - Java Language Basics

Java examples for Language Basics:Number Format

Description

Using floating-point conversion characters.

Demo Code

public class Main 
{
   public static void main(String[] args)
   { //from  w w w  .j av  a  2s . com
      System.out.printf("%e\n", 12345678.9);
      System.out.printf("%e\n", +12345678.9);
      System.out.printf("%e\n", -12345678.9);
      System.out.printf("%E\n", 12345678.9);
      System.out.printf("%f\n", 12345678.9);
      System.out.printf("%g\n", 12345678.9);
      System.out.printf("%G\n", 12345678.9);
   } 
}

Result


Related Tutorials