Tuesday, June 22, 2010

Re: Initializer blocks

Not the "parent" object. Your class is erp.client.Test but the class
of u is erp.client.Test$1. "$1" means the "first" anonymous class of
Test. This is a Java behavior.

Olivier

On Jun 22, 1:22 pm, "ahhat...@gmail.com" <ahhat...@gmail.com> wrote:
> Hi,
> I tried to do the following:
>
> University u = new University()
> {
>                 {
>                         setName("Ahmed");
>                         setPrice(500);
>                 }
>         };
>
>         University u2 = new University();
>         u2.setName("Hassan");
>         u2.setPrice(1000);
>
>         Window.alert(u.toString() + "\n" + u.name + "\n" + u.getPrice() + "\n
> \n" + u2.toString() + "\n" + u2.name + "\n" + u2.getPrice());
>
> I go the following result:
> erp.client.Test$1@1bafdb4
> Ahmed
> 500.0
>
> erp.client.University@1663655
> Hassan
> 1000.0
>
> I don't really understand how did the first object report it self as
> being the parent object.
> May someone explain, please?  And is this behavior GWT specific or
> applies to desktop java too?
>
> Thank you.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate