File tree Expand file tree Collapse file tree 3 files changed +82
-0
lines changed
Expand file tree Collapse file tree 3 files changed +82
-0
lines changed Original file line number Diff line number Diff line change 1+ import java .util .HashSet ;
2+ import java .util .stream .Stream ;
3+
4+ public class HashSetDemo15k {
5+
6+ public static void main (String [] args ) {
7+
8+ HashSet <Integer > set1 = new HashSet <>();
9+ HashSet <String > set2 = new HashSet <>();
10+ set1 .add (1 );
11+ set1 .add (2 );
12+ set1 .add (3 );
13+ set1 .add (4 );
14+
15+ set2 .add ("A" );
16+ set2 .add ("a" );
17+ set2 .add ("B" );
18+ set2 .add ("b" );
19+ set2 .add ("C" );
20+ set2 .add ("c" );
21+
22+ boolean b = set1 .stream ().isParallel ();
23+ System .out .println (b );
24+ Stream s = set1 .parallelStream ();
25+ boolean c = s .isParallel ();
26+ System .out .println (c );
27+
28+ }
29+
30+ }
Original file line number Diff line number Diff line change 1+ import java .util .HashSet ;
2+
3+ public class HashSetDemo15l {
4+ public static void main (String [] args ) {
5+
6+ HashSet <Integer > set1 = new HashSet <>();
7+ HashSet <String > set2 = new HashSet <>();
8+ set1 .add (1 );
9+ set1 .add (2 );
10+ set1 .add (3 );
11+ set1 .add (4 );
12+
13+ set2 .add ("A" );
14+ set2 .add ("a" );
15+ set2 .add ("B" );
16+ set2 .add ("b" );
17+ set2 .add ("C" );
18+ set2 .add ("c" );
19+
20+ set1 .stream ().findFirst ().ifPresent (s -> System .out .println (s ));
21+ set1 .stream ().findFirst ().ifPresent (System .out ::println );
22+
23+ }
24+
25+
26+ }
Original file line number Diff line number Diff line change 1+ import java .util .HashSet ;
2+
3+ public class HashSetDemo15m {
4+ public static void main (String [] args ) {
5+
6+ HashSet <Integer > set1 = new HashSet <>();
7+ HashSet <String > set2 = new HashSet <>();
8+ set1 .add (1 );
9+ set1 .add (2 );
10+ set1 .add (3 );
11+ set1 .add (4 );
12+
13+ set2 .add ("A" );
14+ set2 .add ("a" );
15+ set2 .add ("B" );
16+ set2 .add ("b" );
17+ set2 .add ("C" );
18+ set2 .add ("c" );
19+
20+ set1 .stream ().filter ( e -> (e ==1 )).forEach (System .out ::println );
21+ set2 .stream ().filter ( e -> (e == "A" )).forEach (System .out ::println );
22+
23+
24+ }
25+
26+ }
You can’t perform that action at this time.
0 commit comments