Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f05d857

Browse files
Challenge 42.
array reference and Arrays.stream(..) method
1 parent 212ec2d commit f05d857

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package challenge41_50;
2+
3+
import java.util.Arrays;
4+
5+
/**
6+
* Arrays.stream(..) return stream of primitive type,
7+
* like intStream longStream....
8+
*
9+
*/
10+
public class Challenge_42 {
11+
public static void main( String[] args ) {
12+
int[] anyArray = new int[5];
13+
anyArray[0] = 0;
14+
anyArray[1] = 2;
15+
anyArray[2] = 4;
16+
anyArray[3] = 6;
17+
anyArray[4] = 8;
18+
19+
int[] otherArray = anyArray;
20+
doSum(anyArray);
21+
doSum(otherArray);
22+
23+
Arrays.stream(anyArray)
24+
.forEach(System.out::println);
25+
}
26+
27+
private static void doSum( int[] anyArray ) {
28+
for (int i=0; i<anyArray.length; i++){
29+
anyArray[i] = anyArray[i]+2;
30+
}
31+
}
32+
}
33+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /