day02--数据类型转换_小数的转换
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
package com.inmind;
|
||||||
|
/*
|
||||||
|
小数的强转为整数:直接将小数点后面的数给“砍掉”
|
||||||
|
*/
|
||||||
|
public class Demo04 {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
//定义一个double的浮点数
|
||||||
|
double d = 3.94;
|
||||||
|
// float d = 3.94F;
|
||||||
|
System.out.println("变量d的值:"+d);
|
||||||
|
//将double强转为整数
|
||||||
|
//小范围数据类型 变量名 = (小范围数据类型)大范围数据类型
|
||||||
|
int i = (int)d;
|
||||||
|
System.out.println("变量i的值:"+i);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user