Suppose I have a Java class parameterized on that contains a private T _member. I want to write a default constructor (no arguments), that somehow initializes my T _member to some known, type T specific value (like -1 for Integer, Float.MAX_VALUE for Float…). Is that possible? I tried new T(), but the compiler doesn’t like that. Or do I do nothing, and the default constructor is guaranteed to be called for me?
Share
Every field in Java without an initializer expression is automatically initialized to a known default value. And yes, in this case it is a known value of type T —
null.