What's the difference between a public static method and a public method? Why would you use a public static method?
The methods of the Math class are static. So, in doing
Math.round(average)
the Math class itself is unchanged by what you've done - it only returns a value or acts upon the value you pass.
So - static methods are useful for utilities. Things like
StringUtils.removeWhitespaceFrom(textContent:String):String
or
BrowserUtils.openInNewWindow(url:String):void
It's very unusual that you'd use a static method for anything else. Don't use statics like 'getInstance()' to create Singletons - look into a framework for dependency injection instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With