Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: markspace Newsgroups: comp.lang.java.programmer Subject: Re: Design Patterns Date: Tue, 05 Feb 2013 13:56:26 -0800 Organization: A noiseless patient Spider Lines: 40 Message-ID: References: <3c0d69c3-591d-4d99-8c13-30a0fd1684b3@googlegroups.com> <68pyk4ua9x9m.1nm4lckdwgp86.dlg@40tude.net> <51106eff$0$293$14726298@news.sunsite.dk> <1g6plnhx9njxt$.bx5mrpbwc6mi$.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 5 Feb 2013 21:56:04 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="fba3415ba68d85d643935af2f52f0b4b"; logging-data="9239"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX180/VBf2G++/+aoh2HrkAFAGLWdpHdLslQ=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 In-Reply-To: Cancel-Lock: sha1:atdnmX+JGQoz6CxtJpF4jUJ5NLw= Xref: csiph.com comp.lang.java.programmer:22130 On 2/5/2013 1:43 AM, lipska the kat wrote: > OK, I know I'm probably still being ignored because I've upset some > people but can someone please explain to me exactly what a 'static > class' is (WRT Java of course) Part of the reason I'm generally ignoring your posts is that you don't look obvious stuff up with Google. If you had said "I searched for 'static Java class' but didn't really understand the results," that would a bit different. But at least trying to look stuff up is pretty basic. That said, I think people are using the term loosely and expecting the reader to fill in the gaps. A real static class is a nested class that has no (implied) reference to its enclosing instance. What's being referred to up-thread is just a class with all static methods which also has no public constructor. (I think, I'm not really reading this discussion closely.) It's a standard pattern in Java which is used to make "utility classes." c.f. java.lang.Math, which does exactly this. The standard pattern is: public class UsefulUtils { private UsefulUtils() {} ... public static methods here } This class is effectively final because without a public ctor it cannot be extended. If this class is stateless or has no mutable state, then it is also thread safe, absent some other use of globals.