Ben C. Ben C. - 3 years ago 167
Java Question

What do F and D mean at the end of numeric literals?

I've seen some of this symbols, but I cannot find anything strange with it,

double d = 5D;
float f = 3.0F;

What does the D and F behind 5 exactly means?

Answer Source

Means that these numbers are doubles and floats, respectively. Assume you have

void foo(int x);
void foo(float x);
void foo(double x);

and then you call


the compiler might be stumped. That's why you can say 5, 5f, or 5.0 to specify the type.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download