Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: markspace Newsgroups: comp.lang.java.programmer Subject: Re: Help with methods, classes and parameters Date: Wed, 30 Jul 2014 18:43:44 -0700 Organization: A noiseless patient Spider Lines: 32 Message-ID: References: <53d993b9$0$299$14726298@news.sunsite.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Thu, 31 Jul 2014 01:43:47 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="9358cda03e1e0dfd3c4b757daa608707"; logging-data="28221"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1890+mIqB3+TVkJEVeGlpDH0t8QBj0pKI8=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: <53d993b9$0$299$14726298@news.sunsite.dk> Cancel-Lock: sha1:0sv8FfAQWGADoLi0Ocqynlk+Kgw= Xref: csiph.com comp.lang.java.programmer:29449 On 7/30/2014 5:54 PM, Arne Vajhøj wrote: > One should just be aware that there are some (few but some) cases > where static and inner classes make sense. Just to toss out an example of static methods, when a class's purpose is only to provide functions (and sometimes helpful utility methods), you should make all the methods static, and make the class final and non-instantiable. For example, the java.lang.Math class contains only mathematical functions. All of its methods are static, and the class itself it final and non-instantiable. package myproject; public class MyUtilities { // all private ctors makes the class final and // non-instantiable. private MyUtilities() {} public static void doThis() { ... } public static double calculateThat() { ... } }