JAVA 数据类型扩展
1
public class Demo01 {
public static void main(String[] args) {
String sa= new String("Hello world");
String sb= new String("Hello world");
System.out.println(sa==sb);
String sc= "Hello world";
String sd= "Hello world";
System.out.println(sc==sd);
}
}
运行结果: false
true
原因:由于new开辟的内存空间,所以比较的是内存的地址
2
数据类型优先级 byte->short->char->int->long->float->double
int i=128;
byte b = (byte)i; 高->低需要强制转换类型
double b=i; 低->高 自动转换
浙公网安备 33010602011771号