staticString concat(String[] arr){ return Fold.foldLeft(arr, "", new Function<String, String>(){ publicString apply(String a, String b){ return a + b;
} });
} }
interface Function<I, O> { public O apply(O a, I b);
}
class Fold { publicstatic <I, O> O foldLeft(I[] arr, O initialValue, Function<I, O> func){ for(I x : arr)
initialValue = func.apply(initialValue, x);
return initialValue;
} }
Sponsor Sponsor
beard0
Posted: Thu Nov 17, 2005 10:30 pm Post subject: (No subject)
Err... compiles and runs fine for me. jdk1.5.0_05 & jre1.5.0_05
MysticVegeta
Posted: Thu Nov 17, 2005 10:46 pm Post subject: (No subject)
oh I get the same error, maybe I need to upgrade mine to jdk1.5
wtd
Posted: Thu Nov 17, 2005 10:47 pm Post subject: (No subject)
beard0 wrote:
Err... compiles and runs fine for me. jdk1.5.0_05 & jre1.5.0_05
Same here.
Hikaru79
Posted: Thu Nov 17, 2005 11:25 pm Post subject: (No subject)
Works fine here. If you're doing this in Windows, make sure you run it with
code:
java -cp . Test
. The current directory isn't in the classpath by default. You can also set an environment variable to fix this if you don't want to set it every time.
wtd
Posted: Thu Nov 17, 2005 11:32 pm Post subject: (No subject)
Hikaru79 wrote:
Works fine here. If you're doing this in Windows, make sure you run it with
code:
java -cp . Test
. The current directory isn't in the classpath by default. You can also set an environment variable to fix this if you don't want to set it every time.