zoukankan      html  css  js  c++  java
  • java变量的类型

    变量的类型

    一 按数据类型分:

      1.基本数据类型 : 

          整型 :   byte  (1字节 -   (-128  ~  127))

               short  (2字节)

               int  (4字节)  

               long  (8字节)

          浮点型 :     float   (4字节)

                  double  (8字节)

          字符型 : char  (2字节)

          布尔型 : boolean (只有两个值true/false)

      2.引用数据类型:类,接口,数组

    二 按位置分 :局部变量 vs 成员变量(面向对象再讲)

    public class VarTest3{
        
        public static void main(String[] args){
        
            /*
            整型 :byte(1字节 - (-128 ~ 127)) short(2字节) 
                                int(4字节) long(8字节)
            */
    
            byte b = 127;
            System.out.println(b);
    
            long number = 128L; //声明long型常量须后加‘l’(不建议使用)或‘L’
            System.out.println(number);
    
            System.out.println("--------------------------------------");
            //浮点型 : float(4字节) double(8字节)
            double d = 12.3;
            System.out.println(d);
            float f = 12.5f; //声明float型常量,须后加‘f’或‘F’
            System.out.println(f);
    
            System.out.println("--------------------------------------");
            //字符型 :char(2字节)
            char c = 'a';
            c = '中';
            c = 'キ';
            //第二种表示方式
            c = '
    ';
            //System.out.println("aaa" + c + "bbb"); //"aaa
    bbb"
            //第三种表示方式
            c = 'u0065'; //u0065就unicode码 - 将u0065对应的字符给了c
            c = 65; //是将65对应的字符赋值给了c
            System.out.println(c);
    
            System.out.println("--------------------------------------");
            boolean boo = true;
            boo = false;
            System.out.println(boo);
    
    
            System.out.println("------------------细节--------------------");
            double dd2 = 12.5D; //D,d可以加也可以不加
            dd2 = .5; //0.5
            System.out.println(dd2);
        }
    }

    字符串拼接的演示

    public class VarTest4{
    
        public static void main(String[] args){
        
            int a = 20;
            System.out.println("aaa" + a);
            System.out.println("1" + a);
            System.out.println("aaa" + "ccc"); //"aaaccc"
        
        }
    }
  • 相关阅读:
    csv,exl自动提取表头两列英文字段按英文名称排序显示
    javascript:的用法
    OLAP ODS 项目总结 BI 中的关键
    一些性能查询的SQL 备忘
    ArcGIS 10 SDE for ORACLE 迁移 (3)
    如何测试一个ETL_BI 系统
    ArcGIS 10 SDE for ORACLE 迁移 (2)
    fsck.ext3: Unable to resolve 'LABEL=/design'
    ArcGIS 10 SDE for ORACLE 迁移 (4)
    BI 中关于度量的SQL计算
  • 原文地址:https://www.cnblogs.com/zmy-520131499/p/11041455.html
Copyright © 2011-2022 走看看