You are viewing a single comment's thread. Return to all comments →
Can someone please explain to me why we have to use static initalizer? Why not just do this logic in the main class?
The exercise calls "Java Static Initializer Block" for a reason. =) To teach how to use Static Initializer Block. Sure it's easy to do the same thing in the main class.
I think the way should be used when you wan't make sure the code is called before any other. And the code will not relay on the current coder to invoke.