2016-01-25 18:05:55 -08:00
|
|
|
// arrays/ModifyExisting.java
|
2021-01-31 15:42:31 -07:00
|
|
|
// (c)2021 MindView LLC: see Copyright.txt
|
2016-01-25 18:05:55 -08:00
|
|
|
// We make no guarantees that this code is fit for any purpose.
|
2016-09-23 13:23:35 -06:00
|
|
|
// Visit http://OnJava8.com for more book information.
|
2016-01-25 18:05:55 -08:00
|
|
|
import java.util.*;
|
|
|
|
import onjava.*;
|
|
|
|
import static onjava.ArrayShow.*;
|
|
|
|
|
|
|
|
public class ModifyExisting {
|
|
|
|
public static void main(String[] args) {
|
|
|
|
double[] da = new double[7];
|
|
|
|
Arrays.setAll(da, new Rand.Double()::get);
|
|
|
|
show(da);
|
2021-01-31 15:42:31 -07:00
|
|
|
Arrays.setAll(da, n -> da[n] / 100); // [1]
|
2016-01-25 18:05:55 -08:00
|
|
|
show(da);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Output:
|
2016-07-22 14:45:35 -06:00
|
|
|
[4.83, 2.89, 2.9, 1.97, 3.01, 0.18, 0.99]
|
|
|
|
[0.0483, 0.028900000000000002, 0.028999999999999998,
|
|
|
|
0.0197, 0.0301, 0.0018, 0.009899999999999999]
|
2016-01-25 18:05:55 -08:00
|
|
|
*/
|