OCP 17 Exam - chapter 12 notes - modules
Note: Java Platform Module System was introduced in JDK 9 in project Jigsaw. In Java 25 modules would be available through imports like regular classes. Running and packaging simple module Folde...
Note: Java Platform Module System was introduced in JDK 9 in project Jigsaw. In Java 25 modules would be available through imports like regular classes. Running and packaging simple module Folde...
Let’s consider the following example: var list = List.of(1); var first1 = list.stream().findFirst(); var first2 = list.getFirst(); if (Objects.equals(first1, first2)) { // compiles, just warning i...
try-with-resources can be used only with classes that implement AutoCloseable (also java.io.Closeable which extends AutoCloseable) two or more resources can be defined in one try...
Streams fundamentals “Streams are evaluated lazily, which means intermediate operations are not executed until a terminal operation is invoked.” var ints = new ArrayList<Integer>(); ...
be aware of removing or adding elements to an immutable list (List.of) as it will throw UnsupportedOperationException (review Q.2) how to properly define a collection: // HashSet...
exam may trick us by asking about functional interface that doesn’t exist, e.g. IntegerSupplier instead IntSupplier (review Q.9) or we can be tricked by lambda that doesn’t compile (review Q.1...
Sealed classes and interfaces sealed classes allow us to implement “enum” on class level, so it can be used in switch statement: Sealed v = new Chapter7_SealedClasses().new MyClass(); ...
Interfaces abstract is implicit in interface - automatically added by compiler public abstract interface AbstractIsImplicitInInterface { // abstract is implicit (added by compiler) ...
my protip: always start reading code from main method Inheritance synonyms of subtype when working with classes: subclass, child class synonyms of supertype when working with c...
access modifiers (public, protected, …) and optional modifiers (final, static) can be in any order, but must be before return type void public method() { } // DOES NOT COMPILE: invalid method d...