Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Andreas Leitgeb Newsgroups: comp.lang.java.programmer Subject: Re: Using main from abstract class in concrete class Date: Thu, 17 Aug 2017 18:56:02 -0000 (UTC) Organization: A noiseless patient Spider Lines: 23 Message-ID: References: <87h8xbx0ig.fsf@munus.decebal.nl> <87wp67v6of.fsf@munus.decebal.nl> Reply-To: avl@logic.at Injection-Date: Thu, 17 Aug 2017 18:56:02 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="8549b4f05922d2ebd4291074cd60db11"; logging-data="22726"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18H0tUu/tIFYKaGkVnlnrmk" User-Agent: slrn/1.0.2 (Linux) Cancel-Lock: sha1:k+cEQfrMmpNnnlxLMpq54bKDShk= Xref: csiph.com comp.lang.java.programmer:37259 Cecil Westerhof wrote: > I do something like that now: > public class SQLite3 extends SQL { > // ################ main > public static void main(final String[] args) throws SQLException { > SQL.mainWork(SQLite3.class.getCanonicalName(), args); > } Why not change "mainWork" such, that it accepts a Class ref directly, rather than the canonical name? Maybe even simpler would be to have it accept a SQL ref and just pass it: new SQLite3() There is certainly more than one way to Rome. > I renamed main in the abstract class SQL to mainWork and removed > public. You might want to add "protected", so that derived classes even in other packages can still call it. "protected" is more permissive than default access.