Re: foo(foo) and foo(foo()) etc...

In the hope that it helps clarify further, Java is ONDS according to 
the labels I made up: The functions foo and the class variable foo are 
different things that happen to have the same name.

This example introduces overloading, in which the distinction between 
the two functions comes from its signature - this is another dimension 
that isn't covered by the four categories I suggested, but is orthogonal.

-Chris

Hassan Aït-Kaci wrote:
> Sandro (and the rest who still cling to separate names for separate 
> things),
> please save the enclosed file, run 'javac' on it, then 'java 
> ExampleForSandro'.
> 
> There - convinced?
> 
> -hak
> 
> 
> ------------------------------------------------------------------------
> 
> public class ExampleForSandro
> {
>   static String foo = "Hi Sandro!";
> 
>   static String foo ()
>     {
>       return (foo = "... and the the rest of the RIF gang ... :-)");
>     }
> 
>   static void foo (String s)
>     {
>       System.out.println(s);
>     }
> 
>   static public void main (String[] args)
>     {
>       foo(foo);
>       foo(foo());
>     }
> }

-- 
Dr. Christopher A. Welty                    IBM Watson Research Center
+1.914.784.7055                             19 Skyline Dr.
cawelty@gmail.com                           Hawthorne, NY 10532
http://www.research.ibm.com/people/w/welty

Received on Thursday, 19 April 2007 00:21:36 UTC