Slot 3 Review
Slot 3 Review
CONTENT
2
REGULAR
EXPRESSIONS
3
REGULAR EXPRESSIONS
4
REGULAR EXPRESSIONS in JAVA
• There are classes with methods that take regular expression strings or patterns as
parameters.
o String, Scanner, Formatter, DateTimeFormatter, Duration.
6
REGULAR EXPRESSION CONSTRUCTS
Type Examples
Character Classes . [abc] [a-g] [A-Z] [0-9] [^abc] \d \s \w
Quantifiers * + ?
Boundary matchers ^ $ \b
(or anchors)
Groups ()
You can find these examples and more by looking at Java's Pattern Class API
7
QUANTIFIERS
8
BOUNDARY MATCHERS
9
EXAMPLE
10
EXCEPTION
HANDLING
11
TYPES OF EXCEPTION
• Exceptions are unexpected events or errors that occur during the execution of a
program. Two main types of exceptions in Java: checked exceptions and
unchecked exceptions.
1. Checked Exceptions:
1. These are exceptions that are checked at compile time. They are subclasses of
Exception but not subclasses of RuntimeException.
2. Examples: IOException, SQLException
2. Unchecked Exceptions:
1. These are exceptions that are not checked at compile time. They are subclasses of
RuntimeException.
2. Examples: ArithmeticException, NullPointerException
12
CHECKED EXCEPTIONS
13
finally CLAUSE
14
CheckedExample.java
Sample code
CheckedExample.java
15
FILE I/O
16
TEXT FILES
17
BINARY FILES
18