P
phillip.s.powell
In my native language, PHP, we have a function called array_walk()
http://www.php.net/manual/en/function.array-walk.php
That will walk through an array and perform change on every element in
the array.
I've studied the Collections within Java so far and this seems like the
right way to do it (Collections.replaceAll(List list, Object oldVal,
Object newVal)):
http://java.sun.com/j2se/1.4.2/docs...til.List, java.lang.Object, java.lang.Object)
But looking at the API does not tell me how to do a function-based
"array_walk" like we can so easily do in PHP:
<?
$array = array(1, 2, 3, 4, 5);
@array_walk($array, create_function('&$a', 'return ($a + 1);')); //
WILL RETURN (2, 3, 4, 5, 6)
?>
So how do I do this in Java?
Thanx
Phil
http://www.php.net/manual/en/function.array-walk.php
That will walk through an array and perform change on every element in
the array.
I've studied the Collections within Java so far and this seems like the
right way to do it (Collections.replaceAll(List list, Object oldVal,
Object newVal)):
http://java.sun.com/j2se/1.4.2/docs...til.List, java.lang.Object, java.lang.Object)
But looking at the API does not tell me how to do a function-based
"array_walk" like we can so easily do in PHP:
<?
$array = array(1, 2, 3, 4, 5);
@array_walk($array, create_function('&$a', 'return ($a + 1);')); //
WILL RETURN (2, 3, 4, 5, 6)
?>
So how do I do this in Java?
Thanx
Phil