0%

JavaSE float double

In Java, default floating type is double.
For example, 3.25 is double rather than float unless f is added to the end of 3.25, i.e. 3.25f.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
public class Test{
public void print(byte x){
System.out.print("byte");
}

public void print(int x){
System.out.print("int");
}

public void print(float x){
System.out.print("float");
}

public void print(double x){
System.out.print("double");
}

public void print(Object x){
System.out.print("Object");
}

public static void main(String[] args){
Test t = new Test();
t.print(6.789);
}
}

-> double

Reference