How can is initialize all variables in a Java class at once to zero -
i have java code class variables , rather set them particular value, i'd initialize zero. in c/c++, can memset() on size of structure, how do same thing in java?
primitives default zero. objects default null. see https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html. however, article mentions, relying on default value in java considered bad practice. better practice set them either when declare them or in constructor.
Comments
Post a Comment