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?
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?
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
foo(5)
the compiler might be stumped. That's why you can say 5, 5f, or 5.0 to specify the type.
D stands for double
F for float
you can read up on the basic primitive types of java here
http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
I would like to point out that writing
5.1D or 5.1 : if you don't specify a type letter for a comma number then by default it is double
5 : without the period, by default it is an int
They're format specifiers for float and double literals. When you write 1.0, it's ambiguous as to whether you intend the literal to be a float or double. By writing 1.0f, you're telling Java that you intend the literal to be a float, while using 1.0d specifies that it should be a double. There's also L, which represents long (e.g., 1L is a long 1, as opposed to an int 1)
D stands for double and F stands for float. You will occasionally need to add these modifiers, as 5 is considered an integer in this case, and 3.0 is a double.
As others have mentioned they are the Type definitions, however you will less likely see i or d mentioned as these are the defaults.
float myfloat = 0.5;
will error as the 0.5 is a double as default and you cannot autobox down from double to float (64 -> 32 bits) but
double mydouble = 0.5;
will have no problem