From a75d3d705b98db2ebc3823be6d303d4d905de65b Mon Sep 17 00:00:00 2001 From: Pieter van den Hombergh Date: Fri, 26 Jan 2024 11:14:01 +0100 Subject: [PATCH] added AbstractStringBuilder as example of sealed class in the JDK since Java 20 --- topics/sealedtypes.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topics/sealedtypes.adoc b/topics/sealedtypes.adoc index 37380dd..97654ca 100644 --- a/topics/sealedtypes.adoc +++ b/topics/sealedtypes.adoc @@ -15,7 +15,7 @@ abstract sealed class AbstractStringBuilder implements Appendable, CharSequence } ---- -<1> Meaning that since Java 20 you can no longer extend `AbstractStringBuilder`, +<1> The only allowed extenders of this class are `StringBuilder` and `StringBuffer`, meaning that since Java 20 you can no longer extend `AbstractStringBuilder`, although that would be difficult anyway, because it is a package private class inside the package `java.lang` inside the module `java.base`. In the code snippets below we give a complete example of a simple shape hierarchy.