Java Data Type How to - Declare a float value with E, or e








Question

We would like to know how to declare a float value with E, or e.

Answer

public class MainClass{
//from w  w  w  .j a va2  s.c  om
  public static void main(String[] arg){
     double f1 = 1.496E8;
     double f2 = 9.0E-28; 
  
     System.out.println(f1);

     System.out.println(f2);
     System.out.println(f2 + f1);

  }

}

The code above generates the following result.