Is it null for Object type?

class C {
    int i;
    String s;
    public C() {}
}

Will s be always null?

What about simple types as int? What will that be? Zero or an arbitrary value?

What about local variables in methods?

public void meth() {
    int i;
}

What is the unitialized value of i?


Relying on such default values, however, is generally considered bad programming style.

Ok, what do you suggest we do?

class A {
    String s = "";
    int i = 0;
}

OR:

class A {
    String s;
    int i;
    public A() {
        // default constructor
        s = "";
        i = 0;
    }
}

Which is better and why?

Edit
Report