整数拓展

时间:2021-07-31
本文章向大家介绍整数拓展,主要包括整数拓展使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

整数拓展

  • 进制

  • 字符

  • 字符串


public class Day2
{
   public static void main(String[] args) {
       //整数拓展
       // 二进制:0b 八进制:0 十进制 十六进制:0x
       int i = 10;
       int i2 = 010; //八进制0
       int i3 = 0x10;//十六进制0x 0~9 A~F 16
       System.out.println(i);
       System.out.println(i2);
       System.out.println(i3);
       System.out.println(".................................................................");
       //浮点数拓展   银行业务怎么表示
       //float     有限 离散   舍入误差   接近但不等于
       //double
       //最好完全避免使用浮点数进行比较
       //最好完全避免使用浮点数进行比较
       //最好完全避免使用浮点数进行比较
       //BigDeimal   数学工具类(类)
       float f = 0.1f;
       double d = 1.0/10;

       //不相等
        float g = 5.3483928432747422424242f;
        float j = 5.3483928432747422424242f+1;
       System.out.println(".............................................................................");
       //字符拓展
       char c1 = 'a';
       char c2 = '中';
       System.out.println(c1);
       System.out.println((int) c1);   //强制转换
       System.out.println(c2);
       System.out.println((int) c2);
       //输出
       // a
       //97
       //中
       //20013
       //所有的字符本质还是数字
       //编码 Unicode 2 字节     最大65536
       // U0000   UFFFF

       char c3 = '\u0061';
       //转义字符
       // \t   制表符
       // \n   换行符
       System.out.println("hello\tworld");
       String sa = new String( "hello world");
       String sb = new String("hello,world");
       System.out.println(sa == sb);
       // 结果输出false(两个地址 从内存分析)
       String sc = "hello,world";
       String sd = "hello,world";
       System.out.println(sc == sd);
       // 结果输出true
  }

 

原文地址:https://www.cnblogs.com/tianxiaocheng/p/15084849.html