• 数据的拓展


    数据拓展

    整数拓展

    public class Day08 {
       public static void main(String[] args) {
           //整数拓展; 进制 二进制0b 十进制 八进制0 十六进制0x
           int i3=0b10;//二进制
           int i1=10;//十进制
           int i2= 10;// 八进制0 0在数字前面
           int i4=0x10;//十六进制 0x在数字前面

           System.out.println(i1);
           System.out.println(i2);
           System.out.println(i3);
           System.out.println(i4);

    浮点数拓展

    浮点数是有限的,也是离散的,它存在舍入误差,它大约但又不等于,它接近那个值但又不等于那个值。

    • 最好完全避免使用浮点数进行比较

      //浮点数拓展
      //float
      //double
      //BigDecimal 数学工具类
      float f=0.1f; //0.1后面要加f 跑出来的值是0.1
      double d=0.1d; //0.1后面要加d 跑出来的值是0.1

      System.out.println(f);
      System.out.println(d);
      System.out.println(f==d);//在这里float出来的0.1不等于double出来的0.1 ==号判断它们是否相等 (错误)


      float d1=645599232323232323232323232322f;
      float d2=d1+1;

      System.out.println(d1==d2);//(正确)

    字符拓展

    强制转换输出里面要+(int)

    • 例如System.out.println((int)c1);

    强制转换可以把字符转换为数字,所有字符本质都是数字。

    char类型会涉及一个编码问题,Unicode编码可以处理各种语言的文字,占两个字节,它可以从0~65536。Unicode里面有一个表,里面的数字对应一个字符:97=a 20013=中。

    //字符拓展
    char c1='a'; // 值为 97
    char c2='中';// 值为 20013

    System.out.println((int)c1);//强制转换
    System.out.println((int)c2);//强制转换
    System.out.println(c1);
    System.out.println(c2);

    char c3='u0061'; //输出值为 a
    System.out.println(c3);

    转义字符

    //转义字符
    // 代表空格
    // 代表换行
    // 转义字符有许多,需要的话网上查找
    System.out.println("hello world"); //空格
    System.out.println("hello world"); //换行

    布尔值拓展

    // 布尔值拓展
    boolean flag=true;

    if (flag==true){} //新手程序员使用 上面跟下面的表达意思一样
    if (flag){} //代码要精易读

     

  • 相关阅读:
    实例事件
    实例方法
    Extends Option 扩展选项
    Watch 选项 监控数据
    methods方法选项
    computed Option 计算选项
    propsData Option 全局扩展的数据传递
    component 父子组件
    component-04 动态绑定组件
    component 全局局部组件
  • 原文地址:https://www.cnblogs.com/BoXyu/p/12729225.html
Copyright © 2020-2023  润新知