Re: To static or not to static
Wojtek wrote:
Now that you have read the other posts, what would YOU create as an
example?
I occasionally bump into things that don't make sense. Nothing springs
to mind right away though.
I suppose the String class might be good for an example. It has a ton
of constructors, a bunch of class methods, but also several static
factories too.
So why not have specialized types of strings instead of all those
constructors? Like the InputStream and OutputStream classes do it.
Is it better to have all those static constructors in the base String
class, or should they have gone into a StringUtilities class?
Stuff like that. I can guess at some answers, but if there are hard
reasons it would be interesting to know them.
Mark Space wrote :
Like, why does both javax.swing.SwingUtilities and java.awt.EvenQueue
have the same (static) invokeLater() method?
Yes, but I do Web development not Swing, so I am not familiar with that
entire library. Moreover this is something which I am creating within my
project, not external code.
Many folks speak Servlets here too. Pick an example from that API.
Kind of an interesting bit of history there....
As I understand it, SwingUtilities was intended as a temporary measure.
The main utilities where always in awt.EventQueue. I always assumed
that SwingUtilities were to be used with the javax.swing package and
java.awt might go away at some point, but apparently that's not the case.