java数据类型扩展

`public class demo02 {
public static void main(String[] args) {
//进制 二进制 十进制 八进制0 十六进制0x 0~9 A~F
//int a = 010;
int b = 0x11;
//int c = a + b;
//System.out.println(c);
System.out.println(b);
//System.out.println(a);
System.out.println("************************************************************************");

    //浮点型 float: double:   有限 离散 接近 有误差 不等于
    float num1 = 0.1f;//0.1
    double num2 = 0.1;//num2=1.0/10
    System.out.println(num1);
    System.out.println(num2);
    System.out.println(num1==num2);
    float num3 = 132156465486798f;
    float num4 = 132156465486798f+1;//<=>num4=num3+1;
    System.out.println(num3==num4);
    System.out.println("**********************************************************************************");

    //字符型
    char ch1 = 'a';
    System.out.println((int)ch1);//强制类型转换
    System.out.println('a');
    //所有的字符本质还是数字
    System.out.println((char)97);
    char ch2='\u0061';//
    System.out.println(ch2);
    System.out.println("**********************************************************************************");
    //转义字符
    //\t <=>tab
    //\n 换行
    System.out.println("hello\tworld");
    System.out.println("hello\nworld");

    System.out.println("**********************************************************************************");
    String sa="hello";
    String sb="hello";
    System.out.println(sa==sb);
    System.out.println("**********************************************************************************");
    //布尔值扩展
    boolean flag = true;
    if(flag)//老手
    {
        
    }
    if(flag==true){

    }
}

}

posted @ 2024-08-18 00:48  怂蛋本蛋  阅读(18)  评论(0)    收藏  举报