zoukankan      html  css  js  c++  java
  • 定义 java 基本数据类型

     1 package debug;
     2 
     3 class Demo {
     4     /*
     5      * 定义八种基本数据类型,如下
     6      */
     7     
     8     public static void main(String[] args) {
     9         //define  char type
    10         char a = '1';     //字符类型用单引号
    11         System.out.println(a);
    12         
    13         //define string type
    14         String text = "Hello world";  //字符串类型用双引号
    15         System.out.println(text);
    16         
    17         //define float type
    18         float f = 1.03F;   //单精度浮点类型后面必须要带上F或者f,默认用F
    19         System.out.println(f);
    20         
    21         //define double type
    22         double d = 1.345;  //浮点类型默认为双精度,所以如果定义的是doule类型,后面就不需要再带上F
    23         System.out.println(d);
    24         
    25         //define short type
    26         short s = 100;
    27         System.out.println(s);
    28         
    29         //define int type
    30         int i = 101;
    31         System.out.println(i);
    32         
    33         //define long type
    34         long l = 10000000000L; //定义长整型后面必须要带上L或者l,默认用L
    35         System.out.println(l);
    36         
    37         //define byte type
    38         byte a1 = 102;
    39         System.out.println(a1);
    40         
    41         //define boolean
    42         boolean b = false;
    43         System.out.println(b);
    44         
    45         
    46     }
    47     
    48 }

     输出如下:

    1 1
    2 Hello world
    3 1.03
    4 1.345
    5 100
    6 101
    7 10000000000
    8 102
    9 false
  • 相关阅读:
    5.3Python解析动态页面源代码
    5.2
    5.1selenium
    团队项目第一阶段冲刺第十天
    团队项目第一阶段冲刺第九天
    4.30线程和进程
    团队项目第一阶段冲刺第八天
    Mac下全局安装yarn,报错,没有访问权限解决办法
    Mac下的常用命令行
    I Term2常用快捷键
  • 原文地址:https://www.cnblogs.com/aziji/p/9987846.html
Copyright © 2011-2022 走看看