-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise8.java
More file actions
27 lines (25 loc) · 867 Bytes
/
Copy pathExercise8.java
File metadata and controls
27 lines (25 loc) · 867 Bytes
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
import java.time.LocalDate;
import java.time.Month;
import java.util.ArrayList;
/**
* 6.8.8. Exercise 8
*
* Consider the follow ArrayList:
* write the code necessary to determine if the centennial (1876, at 100 years)
* is present.
*
* Sample output:
*
* centennial present = true
*/
public class Exercise8 {
public static void main(String[] args) {
ArrayList<LocalDate> centennials = new ArrayList<>();
centennials.add(LocalDate.of(1776, Month.JULY, 4));
centennials.add(LocalDate.of(1876, Month.JULY, 4));
centennials.add(LocalDate.of(1976, Month.JULY, 4));
centennials.add(LocalDate.of(2076, Month.JULY, 4));
boolean centennialPresent = centennials.contains(LocalDate.of(1876, Month.JULY, 4));
System.out.println("centennial present = " + centennialPresent);
}
}