Announcing the New Java 17 1Z0-829 Certification Exam and Study Guides!

Scott and Jeanne are thrilled to announce that Oracle has finally announced the new Java 17 1Z0-829 exam! Having worked with Oracle to create the objectives, we’ve been anxiously waiting to let all of our readers know that we already have two books for the new exam well underway:

In fact, you can preorder the Java 17 Complete Study Guide now!

The exam is similar to the Java 11 1Z0-819 that preceded it. The following are some of the key changes Oracle has made to the new exam:

  • Sealed Classes and Records have been added
  • Switch Expressions have been added
  • Pattern Matching has been added
  • Text Blocks have been added
  • Math API is on the exam
  • Date/Time API is back on the exam (previously on the Java 8 exam)
  • Annotations and Security have been removed

We’ll post more details soon about the exam including when you can sign up to take it, as Oracle releases the information!

[2021 kcdc] Algebraic in Java: Pattern Matching

This post is my live blog from KCDC. For more, see the 2021 KCDC live blog TOC

Speaker: Chandra Guntur

Twitter: @cguntur

————————-

Background

  • This is part two of a talk. Part 1 covered algebraic types (ex: enums). Don’t need to have seen it for this talk
  • Pattern matching came froM SNOBOL (string oriented and symbolic language) in 1960s
  • This presentation is in https://github.com/c-guntur/algebraic-in-java

Switch case pattern matching

  • case can be type of object. ex: case Integer i -> “int”
  • Must put “case null” in order to avoid a null pointer
  • Guarded expressions: case Integer i && i < 50
  • Can use same pattern variable name across case statements
  • Flow scoping

If statement pattern matching

Deconstructing is from JDK 18 preview – https://openjdk.java.net/jeps/405 (preview features can change)

  • if (o instanceof Point p)
  • if (o instanceof Point(int x, int y) – deconstruct value. Implicitly type safe because null won’t reach branch (null instanceof X is always false)
  • if (r instanceOf Rect(Point(var x, var y), var lr) – nested deconstruction
  • If have varargs, can match by coordinates/number of elements. Ex Point() matches no params, Point(var a) matches one, Point(var a, …) matches one or more
  • For array, if (o instanceof String[] { String s1, … } – one or more elements in array

Pattern matching isn’t new

  • Always had instanceof
  • Visitor pattern
  • Regular expressions

My take

I’m excited Java is going to be adding a lot of this. The format of presenting from inside IntelliJ is interesting. The presentation was short though. Only half an hour. I liked the answer to my question about scope – pretend there is an else block!