[Javalist] Hogyan kényszerítsünk egy anonymous classt bizonyos dolgok megadására

Gábor Lipták gabor.liptak at gmail.com
2013. Jan. 31., Cs, 13:52:55 CET


Hmm. Valóban. Ok. Ma is tanultam valamit. Szóval az anonymous class nem
definiálhat konstruktort, de meghívhat. Kaptál tőlem egy +1-et :)


2013/1/31 Peter Verhas <peter at verhas.com>

> Akkor nincs szükséged a fluent API-s bohóckodásra sem?
>
>
>
> http://stackoverflow.com/questions/362424/accessing-constructor-of-an-anonymous-class
>
> You can have a constructor in the abstract class that accepts the init
> parameters. The Java spec only specifies that the anonymous class, which is
> the offspring of the (optionally) abstract class or implementation of an
> interface, can not have a constructor by her own right.
>
> The following is absolutely legal and possible:
>
> static abstract class Q{
>     int z;
>     Q(int z){ this.z=z;}
>     void h(){
>         Q me = new Q(1) {
>         };
>     }}
>
> If you have the possibility to write the abstract class yourself, put such
> a constructor there and use fluent API where there is no better solution.
>
> --
> Verhás Péter
> peter at verhas.com
> +36(30)9306805
> skype: verhas
>
>
>
>
> On 2013.01.31., at 13:34, <istvan.ketler at lhsystems.com> wrote:
>
>  Mert a vilagon semmi ertelme nem lenne anonymust a deklaracio helyen
> lehet peldanyositani ott meg meg a befogado metodus lokal valtozoit is
> latja (ha final).
> Sent from my cellular
>
>
>
> Sitz der Gesellschaft / Corporate Headquarters: Lufthansa Systems
> Hungaria Kft, Budapest, Fovarosi Birosag 01-09-463417
> Geschaeftsfuehrung / Management Board: Peter Sipos
>
> *From*: Peter Verhas [mailto:peter at verhas.com]
> *Sent*: Thursday, January 31, 2013 01:20 PM
> *To*: Java lista <javalist at lists.javaforum.hu>
> *Subject*: Re: [Javalist] Hogyan kényszerítsünk egy anonymous classt
> bizonyos dolgok megadására
>
>  Miért nem lehet konstruktor paramétere az anonymous osztálynak?
>
>  --
>    Verhás Péter
> peter at verhas.com
> +36(30)9306805
> skype: verhas
>
>
>
> _______________________________________________
> Javalist mailing list
> Javalist at lists.javaforum.hu
> http://lists.javaforum.hu/mailman/listinfo/javalist
>
>
--------- következő rész ---------
Egy csatolt HTML állomány át lett konvertálva...
URL: <http://lists.javaforum.hu/pipermail/javalist/attachments/20130131/502233b8/attachment.html>


További információk a(z) Javalist levelezőlistáról