next up previous
Next: Exercise: the class BankAccount Up: Unit 04 Previous: Reading of numbers of

Writing of numbers of type double or float

To write a number of type double or float, we can directly use the print or println methods:

Example: The following code fragment

double d = 98d;
System.out.println("d = " + d);
float x = 0.0032f;
System.out.println("x = " + x);
prints on the screen
d = 9.8E1
x = 3.2E-3


next up previous
Next: Exercise: the class BankAccount Up: Unit 04 Previous: Reading of numbers of