Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Modern Java Features

Avatar for Jeanne Boyarsky Jeanne Boyarsky
October 27, 2026
5

Modern Java Features

Avatar for Jeanne Boyarsky

Jeanne Boyarsky

October 27, 2026

Transcript

  1. Modern Java Features Java 21 and beyond Jeanne Boyarsky 10/28/26

    NYJavaSIG https://linktr.ee/jeanneboyarsky 1
  2. Book Giveaway at End Java certs: 8/11/17/21 (future 25) Real

    World Java https://linktr.ee/jeanneboyarsky 3
  3. Disclaimers Some of the material in this presentation appears in

    our certification books. https://linktr.ee/jeanneboyarsky 4
  4. Certs Java 8 Associate 808 Professional 809 Java 11 815

    + 816 819 Java 17 Java 21 Java 25 829 830 831 Foundations 811 https://linktr.ee/jeanneboyarsky 5
  5. Agenda Module Topics 1 Modern Java 2 Concurrency 3 4

    Instanceof/switch expressions/ pattern matching Sequenced Collections + Conclusion https://linktr.ee/jeanneboyarsky 6
  6. Features Feature Preview Instance main 21, 22, 23, 24 25

    Compact source files 21, 22, 23, 24 25 Flexible constructor bodies 22, 23, 24 25 Module imports 23, 24 25 https://linktr.ee/jeanneboyarsky Final 7
  7. Hello Touro public class Hello { public static void main(

    String[] args) { } } 25 void main() { IO.println( "Hello Touro!”); } System.out.println( "Hello Touro!”); • Compact class files • Instance main • IO class @jeanneboyarsky 8
  8. Can use any of these 25 void main() {} void

    main(String[] args) {} void main(String... args) {} static void main() {} public void main() {} public void main(String[] args) {} + more If two, calls one with args @jeanneboyarsky 9
  9. Prologue Rules 25 • Can reference constructor params • Cannot

    reference instance methods • Cannot reference instance variables • Except for setting initial value of unitialized one @jeanneboyarsky 11
  10. Constructor Flow - What prints? public Bridge(int num) { IO.print("n");

    } public class Bridge { { IO.print("i"); } public Bridge() { IO.print("p"); this(1); IO.print("e"); } 25 } public void main() { new Bridge(); } pinepine @jeanneboyarsky 12
  11. Unnamed Variables 22 • _ (single underscore) is valid variable

    name • Restrictions • Cannot read • Cannot write • Can define multiple in same scope • Useful for: catch, lambda, pattern matching, etc @jeanneboyarsky 13
  12. Unnamed Variables 22 // good String _ = "init"; String

    _ = "again"; // no good _ = "write"; IO.println(_); String _; @jeanneboyarsky 14
  13. Module Imports 25 // imports over 50 packages import module

    java.base; import java.util.List; vs import java.util.*; vs import module java.base; @jeanneboyarsky 15
  14. Module Imports Shadowing Code import module.java.sql; Type 25 Imports Module

    imports import java.sql.*; 2 direct packages 3 transitive packages (via requires transitive) 1 service (Driver) Wildcard/package import 50+ classes import java.sql.Date; Import single class @jeanneboyarsky 1 class 16
  15. Module 1 - Question 1 Which lines have compiler errors?

    1: void main(String[] _) { 2: double _ = 0.00; 3: String _ = null; 4: IO.println(_); 5: boolean isNull = _ == null; 6: } A. Line 1 B. Line 2 C. Line 3 D. Line 4 E. Line 5 @jeanneboyarsky 17
  16. Module 1 - Question 1 Which lines have compiler errors?

    1: void main(String[] _) { 2: double _ = 0.00; 3: String _ = null; 4: IO.println(_); 5: boolean isNull = _ == null; 6: } A, D, E A. Line 1 B. Line 2 C. Line 3 D. Line 4 E. Line 5 @jeanneboyarsky 18
  17. Module 1 - Question 2 What are true of line

    5? 1: import java.util.*; 2: import jeanne.List; 3: import module java.base; 4: 5: void main(List list) {} A. The import on line 1 is used for line 5 B. The import on line 2 is used for line 5 C. The import on line 3 is used for line 5 D. This program will run @jeanneboyarsky 19
  18. Module 1 - Question 2 What are true of line

    5? 1: import java.util.*; 2: import jeanne.List; 3: import module java.base; 4: 5: void main(List list) {} B A. The import on line 1 is used for line 5 B. The import on line 2 is used for line 5 C. The import on line 3 is used for line 5 D. This program will run @jeanneboyarsky 20
  19. Module 1 - Question 3 What is the output? Blue(String

    s) { IO.print(s); super(); } private class Blue { { IO.print("i"); } private Blue() { IO.print("c"); this(“l"); } void main() { new Blue(); } } A. cli B. clicli C. Does not compile D. Does not run @jeanneboyarsky 21
  20. Module 1 - Question 3 What is the output? private

    class Blue { { IO.print("i"); } private Blue() { IO.print("c"); this(1); } D Blue(int num) { IO.print(num); super(); } void main() { new Blue(); } } A. cli B. clicli C. Does not compile D. Does not run @jeanneboyarsky 22
  21. Module 1 - Question 4 Which variables can be replaced

    by _? void main(String[] args) { enum Suit { HEART, DIAMOND, SPADE, CLUB }; enum Symbol { ACE, JACK, QUEENS, KING}; record Card(Suit suit, Symbol symbol) {} var card = new Card(Suit.HEART, Symbol.ACE); try { if (card instanceof Card(Suit suit, Symbol symbol)) IO.println(suit); } catch (NullPointerException e) { IO.print("party!"); } } A. args B. card C. symbol D. e @jeanneboyarsky 23
  22. Module 1 - Question 4 Which variables can be replaced

    by _? void main(String[] args) { enum Suit { HEART, DIAMOND, SPADE, CLUB }; enum Symbol { ACE, JACK, QUEENS, KING}; record Card(Suit suit, Symbol symbol) {} var card = new Card(Suit.HEART, Symbol.ACE); try { if (card instanceof Card(Suit suit, Symbol symbol)) IO.println(suit); } catch (NullPointerException e) { IO.print("party!"); } } C, D A. args B. card C. symbol D. e @jeanneboyarsky 24
  23. Agenda Module Topics 1 Modern Java 2 Concurrency 3 4

    Instanceof/switch expressions/ pattern matching Sequenced Collections + Conclusion https://linktr.ee/jeanneboyarsky 25
  24. Features Feature Preview Final Virtual Threads 19, 20 21 Scoped

    Values 21, 22, 23, 24 25 https://linktr.ee/jeanneboyarsky 26
  25. Leaps in Concurrency + Executors Threads 21 + Virtual Threads

    Plus many APIs… https://linktr.ee/jeanneboyarsky 27
  26. Why we need threads Program I’m bored… Do calculation and

    call REST API CPU Do calculation and call REST API Network https://linktr.ee/jeanneboyarsky I’m waiting for a reply 28
  27. Why we need virtual threads Program Platform Thread 1 Platform

    Thread n Still bored… Send to threads Do calculation and call REST API Do calculation and call REST API Proceed Network https://linktr.ee/jeanneboyarsky CPU Still waiting for a reply 29
  28. With virtual threads Program Send to threads Proceed Platform Thread

    1 21 Platform Thread n Virtual Thread 1 Virtual Thread t+1 Do calculation and call REST API Do calculation and call REST API Virtual Thread t Virtual Thread x Do calculation and call REST API Do calculation and call REST API Thanks for the work! CPU Me too! Network https://linktr.ee/jeanneboyarsky 30
  29. When most helpful? 21 • Thousands of threads • Not

    CPU bound https://linktr.ee/jeanneboyarsky 31
  30. Comparing 21 Platform (Traditional) Thread Heavyweight Virtual Thread Tied to

    OS threads Runs on OS thread but doesn’t monopolize Often shortlived Often pooled Lightweight Instance of java.lang.Thread Instance of java.lang.Thread https://linktr.ee/jeanneboyarsky 32
  31. Fill in the blank 21 try (ExecutorService service = Executors._________)

    { service.submit(() -> doStuff()); } Examples: • newSingleThreadExecutor() • newFixedThreadPool(5) • newCachedThreadPool() • newVirtualThreadPerTaskExecutor() https://linktr.ee/jeanneboyarsky 33
  32. Autocloseable 19 Method Java 21 shutdown() shutdownNow() No more tasks,

    but finish ones have Stop tasks in progress close() Calls shutdown by default https://linktr.ee/jeanneboyarsky 34
  33. If need directly Platform Thread Virtual Thread Thread.ofPlatform() Thread.ofVirtual() new

    Thread(…) Not via constructor https://linktr.ee/jeanneboyarsky 21 35
  34. Scoped Values 25 static final ScopedValue<List<String>> SESSIONS = ScopedValue.newInstance(); void

    main() { var sessions = List.of("Java 25", "AI"); ScopedValue.where(SESSIONS, sessions).run( () -> { attend(); }); } void attend() { immutable IO.println(SESSIONS.get()); scoped data } @jeanneboyarsky 36
  35. Module 2 - Question 1 Which is used to create/with

    a virtual thread? (more than 1 is correct) A. Executors.newVirtualThread() B. Executors.newVirtualThreadExecutor() C. Executors.newVirtualThreadPerTaskExecutor() D. new VirtualThread() E. Thread.ofVirtual() F. Thread.ofVirtualThread() https://linktr.ee/jeanneboyarsky 38
  36. Module 2 - Question 1 Which is used to create/with

    a virtual thread? (more than 1 is correct) A. Executors.newVirtualThread() B. Executors.newVirtualThreadExecutor() C, E C. Executors.newVirtualThreadPerTaskExecutor() D. new VirtualThread() E. Thread.ofVirtual() F. Thread.ofVirtualThread() https://linktr.ee/jeanneboyarsky 39
  37. Module 2 - Question 2 Which is used to create/with

    a platform thread? (more than 1 is correct) A. Executors.newCachedThreadPool() B. Executors.newPlatformThreadPool() C. Executors.newPlatformThreadPerTaskExecutor() D. new Thread() E. new PlatformThread() F. Thread.ofPlatform() https://linktr.ee/jeanneboyarsky 40
  38. Module 2 - Question 2 Which is used to create/with

    a platform thread? (more than 1 is correct) A. Executors.newCachedThreadPool() B. Executors.newPlatformThreadPool() A, D, F C. Executors.newPlatformThreadPerTaskExecutor() D. new Thread() E. new PlatformThread() F. Thread.ofPlatform() https://linktr.ee/jeanneboyarsky 41
  39. Module 2 - Question 3 21 What is true doStuff()

    at line v1? try (var service = Executors.newVirtualThreadPerTaskExecutor()) { service.submit(() -> doStuff()); } // line v1 A. doStuff() may be running C. doStuff() completed B. doStuff() was killed D. None of the above https://linktr.ee/jeanneboyarsky 42
  40. Module 2 - Question 3 21 What is true doStuff()

    at line v1? try (var service = Executors.newVirtualThreadPerTaskExecutor()) { service.submit(() -> doStuff()); } C // line v1 A. doStuff() may be running C. doStuff() completed B. doStuff() was killed D. None of the above https://linktr.ee/jeanneboyarsky 43
  41. Module 2 - Question 4 Which types are are immutable

    in SV? static final ScopedValue<XXX>> SV = ScopedValue.newInstance(); A. List B. List<String> C. LocalDateTime D. String @jeanneboyarsky 44
  42. Module 2 - Question 4 Which types are are immutable

    in SV? static final ScopedValue<XXX>> SV = ScopedValue.newInstance(); C, D A. List B. List<String> C. LocalDateTime D. String @jeanneboyarsky 45
  43. Agenda Module Topics 1 Modern Java 2 Concurrency 3 4

    Instanceof/switch expressions/ pattern matching Sequenced Collections + Conclusion https://linktr.ee/jeanneboyarsky 46
  44. Features Feature Preview Final Records 14, 15 16 Sealed classes

    16, 17 18 Pattern Matching for Switch 17, 18, 19, 20 21 Record Patterns 21 Unnamed Variables & Patterns 21 https://linktr.ee/jeanneboyarsky 22 47
  45. Immutable class 16 1. Make fields final and private 2.

    Don’t provide setters 3. No subclasses (ex: make class final) 4. Write constructor taking all fields @jeanneboyarsky 48
  46. POJO 16 • constructor • toString() • hashCode() - more

    rules • equals() - still more rules @jeanneboyarsky 49
  47. Simple Record 16 public record Book (String title, int numPages)

    { } Automatically get * final record * private final instance variables * public accessors New type * constructor taking both fields * equals * hashCode * no instance initializers * toString @jeanneboyarsky 50
  48. Using the Record 16 Book book = new Book("Breaking and

    entering", 289); System.out.println(book.title()); System.out.println(book.toString()); No “get” Outputs: Breaking and entering Book[title=Breaking and entering, numPages=289] @jeanneboyarsky 51
  49. Sealed classes 17 public abstract sealed class Seasons permits Fall,

    Spring, Summer, Winter { } final class Fall extends Seasons {} final class Spring extends Seasons {} final class Summer extends Seasons {} final class Winter extends Seasons {} Seasons Fall Spring Summer @jeanneboyarsky Winter 52
  50. Subclass modifiers Modifer Meaning final Hierarchy ends here non-sealed Others

    can subclass sealed Another layer @jeanneboyarsky 17 53
  51. Pattern matching for if 16 if (num instanceof Integer) {

    Integer numAsInt = (Integer) num; System.out.println(numAsInt); } if (num instanceof Double) { Double numAsDouble = (Double) num; System.out.println(numAsDouble.intValue()); } Pattern variable if (num instanceof Integer numAsInt) { System.out.println(numAsInt); } if (num instanceof Double numAsDouble) { System.out.println(numAsDouble.intValue()); } @jeanneboyarsky 54
  52. Flow Scope if (num instanceof Double d1 && d1.intValue() %

    2 == 0) { 16 Compiles System.out.println(d1.intValue()); } if (num instanceof Double d2 || d2.intValue() % 2 == 0) { System.out.println(d2.intValue()); Does not compile because d2 might not be double } @jeanneboyarsky 55
  53. Does this compile? 16 if (num instanceof Double n) System.out.println(n.intValue());

    if (num instanceof Integer n) System.out.println(n); Yes. Only in scope for if statement @jeanneboyarsky 56
  54. Does this compile? 16 if (num instanceof Double n) System.out.println(n.intValue());

    System.out.println(n.intValue()); No. If statement is over @jeanneboyarsky 57
  55. Does this compile? 16 if (!(num instanceof Double n)) {

    return; } System.out.println(n.intValue()); Yes. Returns early so rest is like an else @jeanneboyarsky 58
  56. Does this compile? 16 if (!(num instanceof Double n)) {

    return; } System.out.println(n.intValue()); if (num instanceof Double n) System.out.println(n.intValue()); No. n is still in scope @jeanneboyarsky 59
  57. Reusing a variable 16 if (num instanceof Integer numAsInt) {

    numAsInt = 6; System.out.println(numAsInt); } Legal. please don’t. @jeanneboyarsky 60
  58. Switch Expressions String store = "Hallmark"; 14 Returns values String

    output = switch(store) { case "Hallmark" -> "KC"; case "Crayola" -> "PA"; default -> "anywhere"; }; System.out.println(output); @jeanneboyarsky 61
  59. Using Pattern Matching 21 null allowed guard clause return switch

    (obj) { case null -> ""; case Integer i when i >= 21 -> "can gamble"; case Integer i -> "too young to gamble"; case String s when "poker".equals(s) -> "table game"; case String s when "craps".equals(s) -> "table game"; case String s -> "other game"; default -> throw new IllegalArgumentException("unexpected type"); }; pattern variable Still Null Pointer if don’t specify case null @jeanneboyarsky 62
  60. Order matters 21 return switch (obj) { case null ->

    ""; case Integer i -> "too young to gamble"; case Integer i when i >= 21 -> "can gamble”; // DOES NOT COMPILE case String s -> "other game"; default -> throw new IllegalArgumentException("unexpected type"); }; Order like catching exceptions! @jeanneboyarsky 63
  61. Enums 21 enum Suit { HEART, DIAMOND, CLUB, SPADE; }

    String symbol(Suit suit) { } return switch (suit) { case HEART -> "♥"; case Suit.DIAMOND -> "♦"; case CLUB -> "♣"; case Suit.SPADE -> "♠"; }; Fails compilation if miss one since no default @jeanneboyarsky 64
  62. Even Here 21 boolean idCheck(Integer age) { boolean check ;

    switch (age) { case Integer i when i <= 40 : check = true; break; default : check = false; break; } return check; } Yes, classic switch @jeanneboyarsky 65
  63. Pattern variable scope 21 boolean idCheck(Integer age) { boolean check

    ; switch (age) { case Integer i when i <= 21 : check = true; // DOES NOT COMPILE case Integer i when i <= 40 : check = true; default : check = false; } return check; } Can’t use pattern variable if fall thru @jeanneboyarsky 66
  64. Record Patterns 21 enum Suit { HEART, DIAMOND, CLUB, SPADE;

    } enum Rank { NUM_2, NUM_3, NUM_4, NUM_5, NUM_6, NUM_7 NUM_8, NUM_9, NUM_10, JACK, QUEEN, KING, ACE; } record Card(Suit suit, Rank rank) { } if (card instanceof Card c) { System.out.println(c.suit()); Deconstructed System.out.println(c.rank()); } if (card instanceof Card(Suit suit, Rank rank)) { System.out.println(suit); System.out.println(rank); } https://linktr.ee/jeanneboyarsky 67
  65. Nested Record Patterns record MultiDeck(int deckNum, Card card) { 21

    } if (multi instanceof MultiDeck(int deckNum, Card(Suit suit, Rank rank))) { System.out.println(deckNum); System.out.println(suit); System.out.println(rank); } https://linktr.ee/jeanneboyarsky 68
  66. Switch pattern matching 21 switch(card) { case Card(Suit suit, Rank

    rank) when suit == Suit.HEART -> System.out.println("Heart"); case Card c -> System.out.println("other"); } https://linktr.ee/jeanneboyarsky 69
  67. Switch pattern matching 21 String str = ""; switch (str)

    { case "heart" -> System.out.println("heart"); } Card card = new Card(Suit.HEART, Rank.NUM_2); switch (card) { case Card(Suit suit, Rank rank) when suit == Suit.HEART -> System.out.println("Heart"); case Card c -> System.out.println("other"); } Must be exhaustive if using “when” https://linktr.ee/jeanneboyarsky 70
  68. What can’t you do? 21 • In switch(x), x still

    can’t be • boolean • float • double • long • _ as pattern (coming in Java 22) • Expanding non-records (coming ?) https://linktr.ee/jeanneboyarsky 71
  69. Module 3 - Question 1 How many lines do you

    need to remove to make this code compile? double odds(Object obj) { return switch (obj) { case String s -> throw new IllegalArgumentException("unknown game"); case String s when "blackjack".equals(s) -> .05; case String s when "baccarat".equals(s) -> .12; case Object o -> throw new IllegalArgumentException("unknown game"); default -> throw new IllegalArgumentException("known game"); }; } A. 0 C. 2 B. 1 D. 3 https://linktr.ee/jeanneboyarsky 72
  70. Module 3 - Question 1 How many lines do you

    need to remove to make this code compile? double odds(Object obj) { return switch (obj) { case String s -> throw new IllegalArgumentException("unknown game"); case String s when "blackjack".equals(s) -> .05; case String s when "baccarat".equals(s) -> .12; case Object o -> throw new IllegalArgumentException("unknown game"); String s & Object default -> throw new IllegalArgumentException("known game"); o or default }; } C A. 0 C. 2 B. 1 D. 3 https://linktr.ee/jeanneboyarsky 73
  71. Module 3 - Question 2 What are the results of

    odds(“slots”) and odds(null) run separately? double odds(String str) { return switch (str) { case String s when "blackjack".equals(s) -> .05; case String s when "baccarat".equals(s) -> .12; case String s -> throw new IllegalArgumentException("unknown game"); }; } A. IllegalArgumentException C. .05 B. NullPointerException D. Does not compile https://linktr.ee/jeanneboyarsky 74
  72. Module 3 - Question 2 What are the results of

    odds(“slots”) and odds(null) run separately? double odds(String str) { return switch (str) { case String s when "blackjack".equals(s) -> .05; case String s when "baccarat".equals(s) -> .12; case String s -> throw new IllegalArgumentException("unknown game"); }; } A, B A. IllegalArgumentException C. .05 B. NullPointerException D. Does not compile https://linktr.ee/jeanneboyarsky 75
  73. Module 3 - Question 3 What does the following print?

    Object robot = "694"; if (robot instanceof String s) { System.out.print("x"); } if (robot instanceof Integer s) { System.out.print("y"); } System.out.println(robot); A. x694 B. xy694 C. y694 D. Does not compile @jeanneboyarsky 76
  74. Module 3 - Question 3 What does the following print?

    Object robot = "694"; if (robot instanceof String s) { System.out.print("x"); } if (robot instanceof Integer s) { System.out.print("y"); } System.out.println(robot); A. x694 B. xy694 A C. y694 D. Does not compile @jeanneboyarsky 77
  75. Module 3 - Question 4 Which lines have s in

    scope? Object robot = "694"; if (robot instanceof String s) { // line 1 } if (robot instanceof int i) { // line 2 } // line 3 A. 1 B. 1 and 3 C. 1, 2 and 3 D. Does not compile @jeanneboyarsky 78
  76. Module 3 - Question 4 Which lines have s in

    scope? Object robot = "694"; if (robot instanceof String s) { // line 1 } if (robot instanceof int i) { (int needs to be // line 2 Integer) } D // line 3 A. 1 B. 1 and 3 C. 1, 2 and 3 D. Does not compile @jeanneboyarsky 79
  77. Module 3 - Question 5 What is true about this

    class? class Sword { int length; public boolean equals(Object o) { if (o instanceof Sword sword) { return length == sword.length; } return false; } // assume hashCode properly implemented } A. equals() is correct B. equals() is incorrect C. equals() does not compile @jeanneboyarsky 80
  78. Module 3 - Question 5 What is true about this

    class? class Sword { int length; public boolean equals(Object o) { if (o instanceof Sword sword) { return length == sword.length; } return false; } // assume hashCode properly implemented A } A. equals() is correct B. equals() is incorrect C. equals() does not compile @jeanneboyarsky 81
  79. Agenda Module Topics 1 Modern Java 2 Concurrency 3 4

    Instanceof/switch expressions/ pattern matching Sequenced Collections + Conclusion https://linktr.ee/jeanneboyarsky 82
  80. Java 17 ArrayList, LinkedList, Deque, TreeSet, TreeMap became sequenced collections

    LinkedHashSet and LinkedHashMap too https://linktr.ee/jeanneboyarsky 84
  81. What does this output? 21 HashSet<String> set = new HashSet<>();

    set.add("Donald"); set.add("Mickey"); set.add("Minnie"); System.out.println(set.iterator().next()); Encounter order undefined(but Mickey on my machine) https://linktr.ee/jeanneboyarsky 85
  82. New APIs SequencedCollection SequencedSet SequencedCollection <E> reversed(); void addFirst(E); void

    addLast(E); E getFirst(); E getLast(); E removeFirst(); E removeLast(); SequencedSet<E> reversed(); SequencedMap SequencedMap<K,V> reversed(); SequencedSet<K> sequencedKeySet(); SequencedCollection<V> sequencedValues(); SequencedSet<Entry<K,V>> sequencedEntrySet(); V putFirst(K, V); V putLast(K, V); Entry<K, V> rstEntry(); Entry<K, V> lastEntry(); Entry<K, V> pollFirstEntry(); Entry<K, V> pollLastEntry(); https://linktr.ee/jeanneboyarsky fi 21 87
  83. Now defined! 21 SequencedSet<String> set = new LinkedHashSet<>(); set.add("Donald"); set.add("Mickey");

    set.add("Minnie"); System.out.println(set.getFirst()); Donald Note: LInkedHashSet not new https://linktr.ee/jeanneboyarsky 88
  84. Module 4 - Question 1 21 How many of these

    lines compile? SequencedCollection<Integer> seq1 = new HashSet<>(); SequencedSet<Integer> seq2 = new HashSet<>(); SequencedMap<Integer> seq3 = new HashSet<>(); SequencedCollection<Integer> seq4 = new TreeSet<>(); SequencedSet<Integer> seq5 = new TreeSet<>(); SequencedMap<Integer> seq6 = new TreeSet<>(); A. One C. Three B. Two D. Four https://linktr.ee/jeanneboyarsky 89
  85. Module 4 - Question 1 21 How many of these

    lines compile? SequencedCollection<Integer> seq1 = new HashSet<>(); SequencedSet<Integer> seq2 = new HashSet<>(); SequencedMap<Integer> seq3 = new HashSet<>(); SequencedCollection<Integer> seq4 = new TreeSet<>(); (seq4=and 5) SequencedSet<Integer> seq5 newseq TreeSet<>(); SequencedMap<Integer> seq6 = new TreeSet<>(); B A. One C. Three B. Two D. Four https://linktr.ee/jeanneboyarsky 90
  86. Bonus: JavaDoc 18 Code Snippets in JavaDoc Inline * {@snippet

    : * if (v.isPresent()) { * System.out.println("v: " + v.get()); * } *} External {@snippet le="ShowOptional.java" region=“example"} Example transformation System.out.println("Hello World!"); // @highlight substring="println" fi https://linktr.ee/jeanneboyarsky 91
  87. Bonus: JavaDoc 23 /// While /** */ uses HTML, ///

    triple slashes use **markdown** /// /// commonmark.org format /// - on odd days, … /// - on even days, … /// /// @return an important number @jeanneboyarsky 92
  88. Bonus: Multi-File Source-Code 22 java Conference.java public class Conference {

    public Conference(List<Speaker> speakers) { } } @jeanneboyarsky 93