float是单精度浮点数,double是双精度浮点数;double类型要比float类型的精度更高。
举个栗子:分别向一个float和double类型的变量中存入圆周率,打印结果
public class PrintRange {
public static void main(String[] args) {
float a = 3.14159265358979323846F;
double b = 3.14159265358979323846;
System.out.println(a);
System.out.println(b);
}
}
集结各类场景实战经验,助你开发运维畅行无忧