zoukankan      html  css  js  c++  java
  • java 变量

    * java开发环境安装
    * 数据类型
    * 创建变量


    数据类型


    * 基本类型4类8种
    * 整型

            byte - 1
            short - 2
            int - 4
            long - 8

    浮点型:

        float - 4 
        double - 8
      

    字符:

        char - 2

    布尔型:

        boolean - 1


    创建变量

        数据类型       变量名    变量值
        int         a     =        1

    下面举个例子:

        public class Variable {
            public static void main(String[] args){
                byte b = 100;
                System.out.println(b);
                short s = 200;
                System.out.println(s);
                
                int i = 500;
                System.out.println(i);
                
                long k = 4545546;
                System.out.println(k);
                
                float f = 1.0F;
                System.out.println(f);
                
                double d = 2.2;
                System.out.println(d);
                
                
                boolean bl = true;
                System.out.println(bl);
                
                char c = 'd';
                System.out.println(c);
            }
        }
        public class Variable {
            public static void main(String[] args){
                byte b = 100;
                System.out.println(b);
                short s = 200;
                System.out.println(s);
                
                int i = 500;
                System.out.println(i);
                
                long k = 4545546;
                System.out.println(k);
                
                float f = 1.0F;
                System.out.println(f);
                
                double d = 2.2;
                System.out.println(d);
                
                
                boolean bl = true;
                System.out.println(bl);
                
                char c = 'd';
                System.out.println(c);
            }
        }

    * 变量的作用范围:定义的大括号内{}

    * 变量不允许重复定义,至少在一个class内

    * 数据类型转换
        * 取值范围小的可以转换成取值范围大的
        * 在运算时,取值范围小的,可以自动转换为取值范围大的;

  • 相关阅读:
    XML 读取器和编写器从URL读取XML
    8月8号 星期五
    080808 晴
    080805
    雨景
    用photoshop批量修改照片(待修改)
    8月7日 晴
    五不
    Android 画渐变的背景
    iOS开发的一些基础知识
  • 原文地址:https://www.cnblogs.com/chenadong/p/9624468.html
Copyright © 2011-2022 走看看