FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java-programming/javaUpdates/src/stream/StreamMethod.java at master · 9146887137/java-programming · GitHub
9146887137
/
java-programming
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
java-programming
/
javaUpdates
/
src
/
stream
/
StreamMethod.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
58 lines (48 loc) · 1.29 KB
Breadcrumbs
java-programming
/
javaUpdates
/
src
/
stream
/
StreamMethod.java
Copy path
File metadata and controls
58 lines (48 loc) · 1.29 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package
stream
;
import
java
.
util
.
ArrayList
;
import
java
.
util
.
Arrays
;
import
java
.
util
.
HashSet
;
import
java
.
util
.
LinkedHashSet
;
import
java
.
util
.
List
;
import
java
.
util
.
TreeSet
;
public
class
StreamMethod
{
public
static
void
main
(
String
[]
args
) {
int
[]
ar
= {
20
,
40
,
56
,
67
,
89
,
23
};
// boolean ans=Arrays.stream(ar).allMatch(a->a>19);
// System.out.println(ans);
// System.out.println(Arrays.stream(ar).average().getAsDouble());
/*
* merge two list and remove duplicate element from list using stream*/
List
<
Integer
>
list
=
new
ArrayList
();
List
<
Integer
>
list1
=
new
ArrayList
();
list
.
add
(
10
);
list1
.
add
(
12
);
list
.
add
(
16
);
list1
.
add
(
16
);
list
.
add
(
1
);
list1
.
add
(
11
);
list
.
add
(
10
);
list
.
add
(
19
);
list1
.
add
(
119
);
list1
.
add
(
45
);
list
.
add
(
19
);
list1
.
add
(
78
);
list
.
addAll
(
list1
);
//merged
list
=
list
.
stream
().
distinct
().
toList
();
System
.
out
.
println
(
list
);
// LinkedHashSet<Integer> lh=new LinkedHashSet<Integer>();
// lh.add(20);
// lh.add(30);
// lh.add(10);
// lh.add(30);
// lh.add(22);
// lh.add(2);
// lh.add(1);
// System.out.println(lh);
//
// TreeSet<Integer> t=new TreeSet<Integer>(lh);
// HashSet<Integer> h=new HashSet<Integer>(lh);
// System.out.println(t);
// System.out.println(h);
}
}
Back
|
FazBrowse Home
|
New Git URL