/**

  • Demo01
  • 描述:

*/
public class Demo01 {
public static void main(String[] args) {
//整数拓展: 进制 二进制0b 十进制0 八进制0x
int i = 10;
int i2 = 010;
int i3 = 0x10;
System.out.println(i);

    System.out.println(i2);

    System.out.println(i3);


    //浮点数拓展
    float f = 0.1f;
    double d = 1.0/10;
    System.out.println(f==d);

    float t1 = 344224;
    float t2 = t1+1;
    System.out.println(t1==t2);

    char a1 = 'f';
    char a2 = '年';
    System.out.println(a1);
    System.out.println(a2);
    System.out.println((int)a1);
    System.out.println((int)a2);

    char a3 = '\u0061';
    System.out.println(a3);

    //转义字符
    System.out.println("hello\tworld");
    System.out.println("hello\nworld");

    String s1 = new String("hello world");
    String s2 = new String("hello world");
    System.out.println(s1==s2);


    String s3 = "hello world";
    String s4 = "hello world";
    System.out.println(s3==s4);
    
    //低到高需要强制转换  byte-int
    int i = 128;
    byte b = (byte) i;
    System.out.println(i);
    System.out.println(b);

    //高到低不需要转换   int-double
    double d = i;
    System.out.println(d);

    System.out.println((int)24.9);
    System.out.println((int)-78.54f);

    char c = 'h';
    int j = c+1;
    System.out.println((char)j);

    int money = 2000000000;
    int years = 30;
    int total = money*years;
    System.out.println(total);
    long total1 = ((long)money)*years;
    System.out.println(total1);

    /*
    注意点:
    1. 不能对布尔值进行转换
    2. 不能转换成不相干的类型
    3. 高容量转换到低容量时,强制转换,低到高时不需要转换
    4. 转换后可能存在内存溢出,或者精度问题
     */
//jdk7特性,数字之间可以用下划线进行分割



}

}

posted on 2022-03-10 13:23  薄绿  阅读(26)  评论(0编辑  收藏  举报