0

I have never come across this type of variable

example: do =20.22d; and double do=20.22d; float pi=3.14f; what is it. i mean what does the letters d and f after the numbers represents. what type of variable is it.

23rd Apr 2018, 6:11 PM
stephen haokip
stephen haokip - avatar
2 odpowiedzi
+ 2
d stands for double and f stands for float. It is more common to use f because a number with a decimal point is always a double by default.
23rd Apr 2018, 6:16 PM
TurtleShell
TurtleShell - avatar
+ 1
first you must understand.. what is literals? int a=10;. 10 is a integers literals. String s="hello"; "hello" is a string literals. float f=10.5 10.5 is a float literals.. now understand the concept.. when we give direct value. like 10 10.5 "hello" these all are called literals ... In java integer literal is treated as a" int" floating literals is treat as a "double" . .. so these word like d, f help us and our compile.. the above value is for double or float..
23rd Apr 2018, 6:51 PM
Arun Tomar
Arun Tomar - avatar