注释 标识符 关键字 数据类型

注释,标识符,关键字

单行注释(comment) //

多行注释/* 添加文本 */

文档注释/**

​ *可以加一些参数

​ */

标识符是大小写敏感的

所有标识符都应该以字母大小写(AAA)(aaa) 美元符$ 下划线_

合法标识符举例;age lary _value __1_value

非法标识符举例;123abc -(减号)salary #abc

关键字类型很多慢慢接触

数据类型(变量必须先定义再使用)

字节(byte)计算机数据处理的基本单位

位(bit)计算机内部数据存储的最小单位 1字节=8位

字符;指计算机使用的字母,数字,字和符号

string(字符串)

基本类型 数值类型 primitive type

整数类型byte(-128------127) 占一个字节范围 short(-32768------32767)占2个字节范围 int(常用)占四个字节范围 (-亿——亿) long占八个字节范围

​ 2浮点类型float(占4个字节) double(占8个字节)

​ 3字符类型char占2个字节

​ boolean类型:占一位其值只有true和false

image

image
image

image-20210415162255701

public class dome2 {
    public static void main(String[] args) {
        //整数扩展  进制  二进制0b  十进制  八进制0 十六进制0x
        //int a = 0x12;
        //int a2 = 0b10;
        //int a3 = 012;
        //int a4 = 10;
       // System.out.println(a2);
        //System.out.println(a);
        //System.out.println(a3);

        //=======================================================================
//     float  有限  离散  舍入误差  大约  接近但不等于
//        double
        //浮点数  银行业务怎么去表示钱
        //bigdecimal  数学工具类
        //最好完全避免用浮点数double  float来进行比较
        //最好完全避免用浮点数double  float来进行比较
        float a = 0.01f;
        double b = 1.0/10;
        System.out.println(a==b);//false
        float a2 = 1234567777888f;//数值很大的情况下
        float a1 = 1 + a2;
        System.out.println(a2==a1);//ture
        //=====================================
        //字符扩展
        System.out.println("=============================");
        char c1 = 'd';
        char c2 = '陈';
        System.out.println(c1);
        System.out.println(c2);
        System.out.println((int)c1);//强制换行//100
        System.out.println((int)c2);//强制换行//38472
        //所有字符本质是数字
        //编码 unicode:(b=100)  2字节  0-65536  excel  2 16 = 65536
        //u0000    uffff
        char f1 = '\u0063';
        System.out.println(f1);//c
        //转义字符
        //   \t  制表符
        //   \n   换行
        //有补充
        System.out.println("hello\bworld");
        System.out.println("=============================");
        String aa =new String("hello.world");
        String ab =new String("hello.world");
        System.out.println(aa==ab);//false
        String ad = "hello.world";
        String ac = "hello.world";
        System.out.println(ad==ac);//true
        //学到对象的时候  内存分析
        //布尔值扩展
        boolean flag = ture;
        if (flag==true){}
        if (flag){}
        
    }

引用类型 类 接口 数组

reference type

image

posted @ 2021-04-15 17:18  陈诚成  阅读(94)  评论(0)    收藏  举报