@jeanneboyarsky
About Me
• Java Champion
• Author
• Developer at
NYC bank for
17+ years
• FIRST Robotics
Mentor
2
Slide 3
Slide 3 text
@jeanneboyarsky
Pause for a Commercial
3
Java 11 certs
•1Z0-815 - Out now
•1Z0-816 - April ETA
Slide 4
Slide 4 text
@jeanneboyarsky
Disclaimer
• A bit of the material is from my
books.
• Some of the material in this
presentation may appear in
our upcoming certification
books.
4
@jeanneboyarsky
Module Flow
•Review lab from previous module
•Lecture/review
•Hands on exercises
•10 minute break
This means if a colleague needs to
call you, the last 15-20 minutes of
each hour is best.
7
Slide 8
Slide 8 text
@jeanneboyarsky
Idiom
• Recurring construct
• Has meaning
• Common approach
8
Slide 9
Slide 9 text
@jeanneboyarsky
Design Patterns
• Typically higher level
• May be language agnostic
9
Slide 10
Slide 10 text
@jeanneboyarsky
Anti-Pattern
• Common “solution”
• Negative effects
10
Slide 11
Slide 11 text
@jeanneboyarsky
Example #1 - What is it?
11
Design Pattern
(Singleton)
Slide 12
Slide 12 text
@jeanneboyarsky
Example #2 - What is it?
12
Idiom
(Pre-Java 8)
Slide 13
Slide 13 text
@jeanneboyarsky
Example #3 - What is it?
13
Anti-pattern
* catches “Exception”
* ignores exception
@jeanneboyarsky
Remove middle
39
Off by one error?
Slide 40
Slide 40 text
@jeanneboyarsky
Ugly regex
40
Slide 41
Slide 41 text
@jeanneboyarsky
Better regex
41
Slide 42
Slide 42 text
@jeanneboyarsky
Regex quick reference
42
0 or more *
1 or more +
0 or 1 ?
any .
three x’s x{3}
range [0-9]
Not in range [^0-9]
Digit \d
White space \s
Word \w
Slide 43
Slide 43 text
@jeanneboyarsky
Splitting on a Regex
43
Slide 44
Slide 44 text
@jeanneboyarsky
Contains only digits
44
Slide 45
Slide 45 text
@jeanneboyarsky
Contains any digits
45
More to regex
Slide 46
Slide 46 text
@jeanneboyarsky
Case Insensitive
46
Slide 47
Slide 47 text
@jeanneboyarsky
Case Insensitive
47
Slide 48
Slide 48 text
@jeanneboyarsky
Multi Line Replace
48
(?m)
Also $1
a
b
c
Slide 49
Slide 49 text
@jeanneboyarsky
Dot All
49
(?s)
Slide 50
Slide 50 text
@jeanneboyarsky
Pattern Idiom
50
Slide 51
Slide 51 text
@jeanneboyarsky
Pattern Replace
51
Slide 52
Slide 52 text
@jeanneboyarsky
Review - How do I?
• Match digit?
• Remove a single match?
• Treat dot as any character?
• Match a character 100 times?
• Loop through matches?
• Match a period?
52
@jeanneboyarsky
Review - How do I?
• Create an immutable copy
• Remove all values less than 5
• Update the value in a map if the
current value is 10
• Return 0 if the value isn’t found
• Find the intersection of two
collections
75
@jeanneboyarsky
Review - What method can…
• Return whether 5/5 values == 7?
• Return whether >=1 values == 7?
• Make a stream smaller?
• Change the order of stream elements?
• Loop through stream elements?
• Ignore the first 2 elements?
• Ignore any elements are the first 2?
92
@jeanneboyarsky
What method for?
• Creating an infinite stream of a times
table?
• Creating a Map that always has two
keys?
• Creating a Map with a custom key/
value?
• Returning an Optional representing the
stream?
106
@jeanneboyarsky
Lab Review
• Did you get them all?
• How did you solve the challenge
problem?
• Did you see how different
methods are useful for
different problems?
109
Slide 110
Slide 110 text
@jeanneboyarsky
Creating a Path
110
Slide 111
Slide 111 text
@jeanneboyarsky
Absolute Path
111
Slide 112
Slide 112 text
@jeanneboyarsky
Separators
112
Windows:
\\ and ;
Mac/Linux:
/ and :
Slide 113
Slide 113 text
@jeanneboyarsky
Read File into String
113
Java 11
Slide 114
Slide 114 text
@jeanneboyarsky
Read File into List
114
Slide 115
Slide 115 text
@jeanneboyarsky
Read File with Stream
115
Slide 116
Slide 116 text
@jeanneboyarsky
Write File from String
116
Java 11
Slide 117
Slide 117 text
@jeanneboyarsky
Write File from List
117
Slide 118
Slide 118 text
@jeanneboyarsky
Append To File
118
Slide 119
Slide 119 text
@jeanneboyarsky
Walk Tree
119
Slide 120
Slide 120 text
@jeanneboyarsky
Convert to unchecked
120
Or
unchecked
wrapper
Slide 121
Slide 121 text
@jeanneboyarsky
Delete File
121
Slide 122
Slide 122 text
@jeanneboyarsky
What API to?
• Read file into a single string?
• Write a List to a file?
• Get rid of a file?
• List all files in directory?
• Add to a file?
• Process file as a
Stream?
122
@jeanneboyarsky
Lab Review
• Did you get them all?
• How did you solve the challenge
problem?
• Which seemed easier - reading
all lines or lines() for the odd/
even problem?
125
Slide 126
Slide 126 text
@jeanneboyarsky
Math
126
Slide 127
Slide 127 text
@jeanneboyarsky
Math
127
Slide 128
Slide 128 text
@jeanneboyarsky
Random
128
Slide 129
Slide 129 text
@jeanneboyarsky
Random
129
Slide 130
Slide 130 text
@jeanneboyarsky
Random
130
Slide 131
Slide 131 text
@jeanneboyarsky
Random
131
Slide 132
Slide 132 text
@jeanneboyarsky
LocalDate
132
Slide 133
Slide 133 text
@jeanneboyarsky
LocalDate
133
Slide 134
Slide 134 text
@jeanneboyarsky
What API to?
• Get today?
• Get July 4th of this year?
• Create a random number
between 2 and 10?
• Get the largest value of two?
• Get a unique id?
134
Slide 135
Slide 135 text
@jeanneboyarsky
Before the last lab:
Tomorrow 10:20am
Java: Did you know that?
+ Win a book
135