class - Java: when would I ever want to use static methods when I can use a singleton instead? -


this question has answer here:

having read difference between static class , singleton pattern?, none of answers list advantages using static method on singleton, leads me wonder why ever want use static methods.

as questions of nature, use right tool job. use singleton when class represents object there can 1 of. use static methods when methods appropriate class members of not rely on specific instance of class.

in general, use best judgment. go clean, precise, maintainable code, keeping overall big picture in mind.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -