In the default construction, what value should be assigned to a generic type field?
class claz<T> { T information; claz(){} //??? } In the default construction, what value should be assigned to a generic type field?
class claz<T> { T information; claz(){} //??? } In the default constructor, it will not be possible to assign any specific value (of a parameterized type ) to a generic other than null .
And in general, it is not necessary to initialize the generic in the default constructor; it will be so, without explicit initialization, null (like any object type).
Source: https://ru.stackoverflow.com/questions/596261/
All Articles
nullno longer in fashion? - ArchDemon Nov.public claz(T arg) { information = arg; }public claz(T arg) { information = arg; }- Alexey Shimanskynullbe assigned an automaton? - user229181