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;  低->高 自动转换



posted @ 2021-07-18 00:28  小鲤鱼23  阅读(18)  评论(0)    收藏  举报