Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

How do I do this?|

Name: javaboi 2009-04-23 11:43

Hi dudes, I'm wondering about how I can do something like this in java

func(){print "hi"}
func2(){print " there"}

tab[] funcs = {"func", "func2"}
for(int i = 0; i < 2; i++){
funcs[i]()}

resulting in "hi there"

I think this is called anonymous functions in some other codans.

Name: Anonymous 2009-04-23 12:53

ENTERPRISE enough for you?

public class stofnlok {
    public static void func() { System.out.print("hi"); }
    public static void func2() { System.out.println(" there"); }

    public static void main(String args[])
    {
        try {
            String funcs[] = { "func", "func2" };
            for (String f : funcs)
                stofnlok.class.getMethod(f).invoke(null);
        } catch (Throwable e) {
            System.out.println("WHO GIVES A FUCK, YOU PATHETIC EXCUSE FOR A LANGUAGE?");
        }
    }
}
/*
 GRUNNUR
 ; */

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List