天天看点

变量初始化

 在类的实例化过程中,成员变量如果没有赋值的话默认都会进行初始化赋值,以下是我写的小demo。

Variable类

public class Variable {

    short s;
    int i;
    long l;
    byte b;
    char c;
    float f;
    double d;
    String str;
    
    public static void main(String[] args) {
        Variable v = new Variable();
        System.out.println("v = " + v);
    }

}
           

输出结果 

变量初始化