Re: Re: Curious about method handling

Isaac Gouy <[email protected]> Thu, 4 Aug 2005 17:21:13 -0700 (PDT)
Newsgroups gmane.comp.lang.nice.general
Message-ID <[email protected]>
> > String f() =3D "Hello World";
> >=20
> > class A {
> >   String greeting =3D "Hello World";
> >   String g() =3D this.greeting;
> > }
> >=20
> > void main(String[] args) {
> >   println( f );
> >   println( ( new A() ).g );
> > }

1) As you've seen, instead of applying f and printing the result, this
just prints a representation of the function f
   println( f );

Do this to apply the function
   println( f() );

2) These both mean the same
   println( new A().g );
   println( new A().g() );

So the interesting question is how do a get a reference to a non-static
method of class A.


This gives a compiler error
> repeatOnA( new A(), A.g );
Class test.A has no static method or static field named g


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around=20
http://mail.yahoo.com=20


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practic=
es
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & Q=
A
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf