Step7 基本数据类型及unicode相关转义扩展

public class Demo03 {
   
public static void main(String[] args) {
       
//整数拓展:进制、二进制(0b开头)、八进制(0开头)、十进制、十六进制(0x开头)
        int n = 10;
       
int n1 = 010//8进制0开头
        /*16进制 0x开头0~9 A~F 16*/
       
int n2 = 0x10; //16进制0x开头 0~9 A~F 16

       
System.out.println(n);
        System.
out.println(n1);
        System.
out.println(n2);
  System.
out.println("=========================================================================================");
/*
* ======================================================================================================================
* */
        //
浮点数(小数)拓展:银行业务怎么表示?钱
        //flaot
        //double

       
float f = 0.1f;
       
double d = 0.1;

       
/*false*/
       
System.out.println(f==d);

        System.
out.println(f);
        System.
out.println(d);

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

       
/*true*/
       
System.out.println(d1==d2);

       
//为何不等的两个浮点数操作后却相等==

        //因为float浮点数所表示的字长是有限的也是离散的
        //会舍入误差,很多数据没办法精确表示
        //结果只能是大约数,接近但不等于

        /*重点*/
        //
最好完全避免使用浮点数float进行比较

        /**
         *
字符串拓展
         **/
       
System.out.println("========================================================================================");

       
char c = 'a';
       
char c1 = '';

        System.
out.println(c);
        System.
out.println((int)c);//强制转换
        System.out.println(c1);
        System.
out.println((int)c1);//强制转换
        //强制转换可以把字符变成数字

        /*是所有的字符本质还是数字,所以在此情况下可以强制转换*/

        /**Unicode
编码占2字节(byte,最多可表示65536个字符即216次方,即Excel表格原始长度*/

        /**Unicode
有个对应编码表,如97=a65=A*/

        /**
涉及相关unicode代码表中的字符都可以进行强制转换*/

        /**
区间在U0000-UFFFF*/

        /**Unicode
编码规范指定标准*/
        //
把世界上所有能出现的字符,都为其分配一个数字来表示,比如,数字U+7F57被分配给了汉字中的""字。Unicode编码的标准里字符数量一直实在
        //新增(包括一些稀有字符,当然emoji表情字符也属于unicode编码哈哈),193月刚发布了Unicode12.0版本,比之前的版本新增了一些字符
        //现在在标准中的字符一共有137929个,而Unicode编码目前规划了U+0000U+10FFFFunicode编码(以世界上字符的数量应该是很久不会考虑
        //扩展的),算一下目前还剩下9761831114112-137929)个代码点,这976183个代码点是规划在unicode中的数字,但是还没被分配对应的字符。

        /*https://www.cnblogs.com/hahlzj/p/11908713.html*/

       
System.out.println("----------------------------------------------------------------------------------------");
       
//-------------------------------------------------------------------------------------------------------------

        /**unicode
转义输出*/
        /**unicode
代码区间U0000-UFFFF*/
       
char c3 = '\u0061';//转义字符
        System.out.println(c3);
       
char c4 = '\uFFFF';//转义字符
        System.out.println(c4);

       
/*转义字符*/

        // \t
制表符(空格)
        System.out.println("Hey\t2opz");
       
// \n换行
        System.out.println("Hey\n2opz");

       
/**拓展链接
         * https://baike.baidu.com/item/%E8%BD%AC%E4%B9%89%E5%AD%97%E7%AC%A6/86397?fr=aladdin
         *
常用转义字符 https://www.cnblogs.com/EasonJim/p/6561576.html
         * */


       
System.out.println("-----------------------------------------------------------------------------------------");

       
/*String拓展*/

        /**
同等赋值条件下,za=zb*/
        //sout
执行结果为false
       
String za = new String("Hey\t2opz");
        String zb =
new String("Hey\t2opz");
        System.
out.println(za==zb);

       
/**语句不同情况下,za==zb*/
        //sout
执行结果为true
        //
(关系到对象与内存分析)
        String xa = "Hey\t2opz";
        String xb =
"Hey\t2opz";
        System.
out.println(xa==xb);

       
/**布尔值拓展*/

       
boolean example = true;
       
/**ifexample==true{sout语句}  ==  if(example){}*/
        /*
新手写法*/
       
if (example==true){
            System.
out.println("I just wanna B Ur Dad");
        }

       
/*老手程序员,less is more*/
       
if (example){
            System.
out.println("NO WAY SIR");
        }
    }
}

运行结果依次附上:

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值