0
What does "double" do in java?
Variables
3 odpowiedzi
+ 7
*Taken from the JAVA lesson:
- double: for floating-point or real numbers with optional decimal points and fractional parts in fixed or scientific notations, such as 3.1416, -55.66.
In other words, it's used for declaring decimal numbers (the ones with dots in between)... You've got examples above.
*Program examples using "double":
----------------------------------------------
...
double pi=3.14;
System.out.println(pi);
...
°Output: 3.14
----------------------------------------------
...
double n=5;
System.out.println(n);
...
°Output: 5.0
----------------------------------------------
+ 6
Double is a primitive data type for decimal numbers like 2.5; 1.333; 4.0...
https://www.baeldung.com/java-primitives
+ 2
Thanks