tw4ld6 发表于 2024-10-5 07:00:33

Java基本,数据类型,类型转换,Java转义符,Java中的进制


    <h1 style="color: black; text-align: left; margin-bottom: 10px;">数据类型</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">强类型语言:<span style="color: black;">需求</span>所有变量先定义后<span style="color: black;">运用</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;"><span style="color: black;">重视</span>:字符串不属于基本数据类型,属于引用数据类型;字符属于基本数据类型。</span></strong></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/3bb4d282e2154682a06f0bc609c9f76d~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728298708&amp;x-signature=wBNr5nX%2Br2kb8NSctzbGII%2B%2Bg6o%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/0dafc3f6bded4b6e915bb541405df0e6~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728298708&amp;x-signature=ne0c4wV83MIWDmGU6d%2BZVtgACko%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">基本数据类型的封装类按住</span><strong style="color: blue;"><span style="color: black;">ctrl+封装</span></strong><span style="color: black;">类名字可<span style="color: black;">转</span>底层</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">浮点数:是有舍入误差的,浮点数之间接近但不相等,</span><strong style="color: blue;"><span style="color: black;"><span style="color: black;">因此呢</span>在银行业务计算钱时大多<span style="color: black;">运用</span>类BigDecimal类;</span></strong></p><span style="color: black;">//强制转换</span>
    <span style="color: black;">char</span> c=<span style="color: black;">a</span>;
    system.<span style="color: black;">out</span>.print((<span style="color: black;">int</span>)c);<span style="color: black;">//强制转化为int类型</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">char字符都<span style="color: black;">能够</span>转化为数字,char<span style="color: black;">运用</span>Unicode编码表</span></p><span style="color: black;">char</span> c=<span style="color: black;">\u0061</span>;<span style="color: black;">//\u<span style="color: black;">暗示</span>转义</span>
    system.<span style="color: black;">out</span>.print(c);<span style="color: black;">//输出a</span>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">转义符</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">Java中的转义字符:会被Java识别成特殊含义的字符</span></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;">
      <div style="color: black; text-align: left; margin-bottom: 10px;">
            <div style="color: black; text-align: left; margin-bottom: 10px;">
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;"><span style="color: black;">转义字符</span></span></strong></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;"><span style="color: black;"><span style="color: black;">道理</span></span></span></strong></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">\b</span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">退格(BS) ,将当前位置移到前一列</span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">\f</span></span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">换页(FF),将当前位置移到下页开头</span></span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">\n</span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">换行(LF),将当前位置移到下一行开头</span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">\r</span></span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">回车(CR),将当前位置移到本行开头</span></span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">\t</span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">水平制(HT)(跳到下一个TAB位置)</span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">\v</span></span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">垂直制表(VT)</span></span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">\\</span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">表率</span>一个反斜线字符\</span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">\</span></span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">表率</span>一个单引号(撇号)字符</span></span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">\"</span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">表率</span>一个双引号字符</span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">\0</span></span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">空字符(NULL)</span></span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">\ddd</span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">1到3位八进制数所<span style="color: black;">表率</span>的任意字符,三位八进制</span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">\xhh</span></span></p>
                <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">1到2位十六进制所<span style="color: black;">表率</span>的任意字符,二位十六进制</span></span></p>
            </div>
      </div>
    </div>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">包装类型与基本类型的转换</h1><span style="color: black;"><span style="color: black;">运用</span>包装类的构造函数将基本类型的变量手动装箱为相应的包装类:Boolean(boolean value)、 Character(char value)、 Integer(int value)、 Long(long value)、 Float(float value)、 Double(double value)</span><span style="color: black;"><span style="color: black;">运用</span>的包装类静态<span style="color: black;">办法</span> valueOf() 将基本类型的变量手动装箱为相应的包装类</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">Integer i = Integer.valueOf(1); // 手动装箱 <span style="color: black;">重视</span>:valueOf() 内部是用的 new <span style="color: black;">办法</span>来构造对象的。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">3.调用包装类中 ××Value() 的实例<span style="color: black;">办法</span>将包装类型手动拆箱为任意类型的简单类型数据,以 Interger 包装类为例,Interger 包装类的所有<span style="color: black;">办法</span>:利用这种<span style="color: black;">办法</span>,<span style="color: black;">亦</span><span style="color: black;">能够</span>实现<span style="color: black;">区别</span>数值型变量间的转换,例如,<span style="color: black;">针对</span>一个双精度实型类,intValue() <span style="color: black;">能够</span>得到其对应的整型变量,而 doubleValue() <span style="color: black;">能够</span>得到其对应的双精度实型变量。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">4.调用包装类的串转换<span style="color: black;">办法</span>:X.toString();</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">自动转换:X+""`</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">运用</span> String 的<span style="color: black;">办法</span>:String.volueOf(X);`</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">强制转换<span style="color: black;">重视</span>点:1.<span style="color: black;">不可</span>对Boolean类型进行转换,2.高容量—&gt;底容量需要强制转换,3.转换存在内存溢出<span style="color: black;">或</span>精度问题,操作比<span style="color: black;">很强</span>的数时<span style="color: black;">重视</span>内存溢出</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">高容量—&gt;底容量:double—&gt;float—&gt;int—&gt;byte,short,char</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">JDK7新特性:数字见<span style="color: black;">能够</span>用下划线<span style="color: black;">掰开</span>,程序不会识别:int a=10_0000_0000;</span></p>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">进制(整数)</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">Java中二进制以0b开头:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">Java中十进制:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">Java中八进制以0开头:int i=010;</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">Java中十六进制以0x开头:int i=0x10;(0~9A~F)</span></p>




j8typz 发表于 2024-10-18 05:49:40

网站建设seio论坛http://www.fok120.com/
页: [1]
查看完整版本: Java基本,数据类型,类型转换,Java转义符,Java中的进制