X-Received: by 10.66.72.232 with SMTP id g8mr7875803pav.23.1357521898198; Sun, 06 Jan 2013 17:24:58 -0800 (PST) X-Received: by 10.50.106.225 with SMTP id gx1mr1330990igb.8.1357521898138; Sun, 06 Jan 2013 17:24:58 -0800 (PST) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!f6no10655832pbd.1!news-out.google.com!s9ni88763pbb.0!nntp.google.com!b8no3504987pbd.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.java.programmer Date: Sun, 6 Jan 2013 17:24:57 -0800 (PST) In-Reply-To: <919a1e82-bb3d-409b-a3c6-a6fe8e09b1c5@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=173.164.137.214; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T NNTP-Posting-Host: 173.164.137.214 References: <8889b1c7-4198-4d54-8fbc-8fa0ef8608a3@googlegroups.com> <919a1e82-bb3d-409b-a3c6-a6fe8e09b1c5@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <53b5b13b-4baa-4c64-bead-404bf0073da4@googlegroups.com> Subject: Re: "Hello world!" without a public class? From: Lew Injection-Date: Mon, 07 Jan 2013 01:24:58 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: csiph.com comp.lang.java.programmer:21095 Aryeh M. Friedman wrote: > On inner classes: > ... > (yes it does get compiled into something very close to inner classes [not= nested if I remember the jargon correctly] Terminology: A nested type (class or interface) is a member of another typ= e.=20 (JLS =A78.5) There are two kinds of nested classes, static and inner, per the JLS.=20 By definition, an inner class is a nested class whose declaration does not = include the keyword 'static'. "The static keyword may modify the declaration of a member type C within th= e=20 body of a non-inner class or interface T. Its effect is to declare that C i= s=20 not an inner class." (JLS =A78.5.1) > but no where near as ugly): These get compiled exactly into inner classes. > Foo.java: >=20 > public enum Foo > { > ACK { @Override > public void doSomething(SomeClass arg) > { > do what ever for ACK > } > }, > ... > } In this case the enum, itself a cover for compiler-supported boilerplate fo= r a class with static constant members, also covers for the boilerplate of inne= r=20 class declarations in those constants. Much as the lambdas I mentioned earlier cover for the boilerplate of inner- class declarations of SAM interface implementations. Neither of these work without inner classes, so your proposal to eliminate= =20 inner classes would break them. > Fred.java: > ... > and voila much more readable then putting a whole rats nest of stuff in t= he initialization of arr Perhaps, but it doesn't prove the point, because it relies on inner classes= . And your claim that it's "much more readable" is not really proven. public abstract class Bar { private final String rep; abstract public void doSomething(Some arg); private Bar(String r)=20 { this.rep =3D r; } public static final BAR =3D new Bar("BAR")=20 { @Override public void doSomething(Some arg)=20 {=20 // do what ever for BAR=20 }=20 }; } The only part of the anonymous class declaration that differs is the=20 new Bar("BAR")=20 Not even "much" different in readability, let alone "very much". --=20 Lew