java变量、数据类型

public class Test {
    public static void main(String[] args) {
        //变量
        //数据类型 变量名;
        //基本数据类型:
        //一个字节8位
            //整型 byte(1)、short(2)、int(4)、long(8)
            //浮点 float、double
            //字符 char''
            //布尔boolean (true、false)
        //引用数据类型:
            //数组
            ////接口
        int i;//变量声明
        //变量的赋值
        //初始化指第一次赋值
        i = 1;
        i = 2;
        System.out.println(i);
        //+ - * / %
        // =
        // == >= <= !=
        //&& ||
        //& |
        System.out.println(1+2+"3");
        System.out.println(1+"2"+3);
        System.out.println("1"+2+3);
    }
    public void get(){
        int i;
        i = 3;
        System.out.println(i);
    }
    //变量的作用域,一个变量的作用域是包在其最近的大括号{}
}

运行结果:

2
33
123
123

猜你喜欢

转载自www.cnblogs.com/makangning/p/9379215.html