You are viewing a single comment's thread. Return to all comments →
What's missing from all these explanations is they all focus on "how it works" and not "why you would want to do it" which remains still partiallly a mystery to me. Apart from allowing one to run commands out of sequence - and why would you want to do that? - the best explanation of what it's for that I could find is...
"The advantage of private static methods is that they can be reused later if you need to reinitialize the class variable. So, you kind of get more flexibility with a private static method in comparison to the corresponding static initialization block. This should not mislead that a 'public' static method can't do the same. But, we are talking about a way of initializing a class variable and there is hardly any reason to make such a method 'public'. "
Agree, especially with such a simplistic example, the motivation for using this made so little sense to me.