I was wondering whether I should initialize class members in java with an initial value and then change that value to some other given value in the constructor, or should I avoid doing such a thing?
code example
public class Test {
private int value = 5;
public Test(int value) {
this.value = value;
}
}
If not specified,:
primitive byte
s, short
s, int
s, long
s, float
s and double
s are initialized to 0
boolean
s are initialized to false
Objects are initialized to null