数据类型扩展
public class demo02 {
public static void main (String[] args) {
//整数拓展 进制: 二进制0b 八进制0 十进制 十六进制 0x
int i1 = 10;
int i2 = 010;
int i3 = 0x10;
System.out.println (i1);
System.out.println (i2);//八进制
System.out.println (i3);//十六进制
float f = 0.1f;
double d = 1.0 / 10;
System.out.println (f);
System.out.println (d);
System.out.println (f == d);
float d1 = 12311231321321f;
float d2 = d1 + 1;
System.out.println (d1 == d2);//true
//字符拓展
char f1 = 'A';
char f2 = '中';
System.out.println ((int) f1);//强制转换成int类型
System.out.println ((int) f2);
char f3 = '\u0061';
System.out.println (f3);
System.out.println ("Hello\tWorld");
String sa = new String ("hello word");
String sb = new String ("hello word");
System.out.println (sa == sb);//false
String sc = "hello world";
String sd = "hello world";
System.out.println (sc==sd);//true
//布尔值扩展
boolean flag = true;
if (flag==true){}
if (flag){}
}
}

浙公网安备 33010602011771号