FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java8Examples/Java8Examples/src/match/MatchingExample.java at master · suatoz/java8Examples · GitHub
suatoz
/
java8Examples
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
java8Examples
/
Java8Examples
/
src
/
match
/
MatchingExample.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
34 lines (26 loc) · 893 Bytes
Breadcrumbs
java8Examples
/
Java8Examples
/
src
/
match
/
MatchingExample.java
Copy path
File metadata and controls
34 lines (26 loc) · 893 Bytes
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
package
match
;
import
java
.
util
.
Arrays
;
import
java
.
util
.
stream
.
IntStream
;
import
java
.
util
.
stream
.
LongStream
;
public
class
MatchingExample
{
static
String
[]
alphabet
=
new
String
[]{
"A"
,
"B"
,
"C"
,
"D"
};
static
int
[]
number
= {
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
};
static
long
[]
numberLong
= {
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
};
public
static
void
main
(
String
[]
args
) {
matchingEx
();
matchingEx2
();
}
private
static
void
matchingEx
() {
boolean
result
=
Arrays
.
stream
(
alphabet
).
anyMatch
(
c
->
c
.
equals
(
"A"
) ||
c
.
equals
(
"B"
));
//("A"::equals);
if
(
result
)
System
.
out
.
println
(
"A or B"
);
}
private
static
void
matchingEx2
() {
boolean
result
=
IntStream
.
of
(
number
).
anyMatch
(
x
->
x
==
9
);
if
(
result
)
System
.
out
.
println
(
"IntStream -> 9"
);
boolean
result2
=
LongStream
.
of
(
numberLong
).
anyMatch
(
x
->
x
==
1
);
if
(
result2
)
System
.
out
.
println
(
"LongStream -> 1"
);
}
}
Back
|
FazBrowse Home
|
New Git URL