FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java_upgrade/src/main/java/UseProducts.java at main · ps4/java_upgrade · GitHub
ps4
/
java_upgrade
Public
forked from
kousen/java_upgrade
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
java_upgrade
/
src
/
main
/
java
/
UseProducts.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
25 lines (20 loc) · 980 Bytes
Breadcrumbs
java_upgrade
/
src
/
main
/
java
/
UseProducts.java
Copy path
File metadata and controls
25 lines (20 loc) · 980 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
import
java
.
util
.
Arrays
;
import
java
.
util
.
List
;
import
java
.
util
.
logging
.
Logger
;
import
java
.
util
.
stream
.
Collectors
;
public
class
UseProducts
{
private
static
final
Logger
logger
=
Logger
.
getLogger
(
UseProducts
.
class
.
getName
());
public
static
void
main
(
String
[]
args
) {
List
<
Product
>
products
=
Arrays
.
asList
(
new
Product
(
"football"
,
10
),
new
Product
(
"basketball"
,
12
),
new
Product
(
"baseball"
,
5
));
List
<
String
>
names
=
products
.
stream
()
// Stream<Product>
.
map
(
Product
::
getName
)
// Stream<String>
// .peek(System.out::println)
.
collect
(
Collectors
.
toList
());
// complex string arg always gets formed!
// Arguments to methods always get evaluated
logger
.
info
(
"Product not found; available products are: "
+
names
);
// supplier.get() only invoked if loggable
logger
.
info
(() ->
"Product not found; available products are: "
+
names
);
}
}
Back
|
FazBrowse Home
|
New Git URL