When you do things right, people won't be sure you've done anything at all.
Aspiring Java Programmer.
I would hope you don't use an initialiser nor a constructor to print output to the screen. You might use print statements for debugging but printing output usually belongs inside methods rather than initialisers.John Pacuta wrote:. . . how I would do that using an instance initialization block and with a constructor and then explain the difference. . . .
Aspiring Java Programmer.
"Disappointing" and "Utterly Horrible" are not equal.
What is the point to them? If you are going to initialise a field to a default value every time, it is possible to do that in the constructor, or with a declaration‑and‑initialisation combined. There are also possible problems about order of execution with initialisers, which I read about in Java Puzzlers by Bloch and Gafter, but I have forgotten the details.Mike. J. Thompson wrote:. . . Out of interest, why don't you like instance initializer blocks Campbell?
Good point. I know Winston G would agree with you there.Mike. J. Thompson wrote:Personally I would say to leave the final modifiers there . . .
Trying to collect the broken pieces of my life,in the process of making out a beautiful picture out of it.
Sachin Tripathi wrote:1-Put the code separetly in all constructors
Sachin Tripathi wrote:2-Put it into a method...
Trying to collect the broken pieces of my life,in the process of making out a beautiful picture out of it.
Let nothing stop you! Not even this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|