java数据类型及其转换
基本数据类型
-
强语言类型:变量要严格符合规定,先定义后才能使用
-
弱语言类型:JavaScrip 转换
- byte–>short>char–>int–>long–>float–>double
package com.sund.base;
public class Demo04 {
public static void main(String[] args) {
int i = 128;
byte s = (byte)i;
float d = i;
System.out.println(s);
System.out.println(d);
System.out.println("=====================");
System.out.println((int)3.14);
System.out.println((int)3.66F);
System.out.println("================");
int money = 10_0000_0000;
int years = 30;
int total = money*years;
long total2 = money*years;
System.out.println(total);
System.out.println(total2);
long total3 = money*((long)years);
System.out.println(total3);
}
}
|