├── .gitignore ├── Chapter01 ├── P01_TextBlockSQLJSONHTML │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P02_TextBlockDelimiters │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P03_TextBlockIndentation │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P04_TextBlockRemovingIncidentalWhiteSpace │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P05_TextBlockJustForReadability │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P06_TextBlockEscaping │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P07_TextBlockTranslateEscapes │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── Strings.java ├── P08_TextBlockEmbeddedExpressions │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P08_TextBlockEmbeddedExpressionsBenchmark │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P10_TextBlockStringLiteralIntermix │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P11_RegexNamedGroups │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P12_TextBlockIsomorphic │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── Strings.java ├── P13_StringConcatJDK11 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── Strings.java ├── P13_StringConcatJDK11Benchmark │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P13_StringConcatJDK8 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── Strings.java ├── P13_StringConcatJDK8Benchmark │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P14_IntegerToStringBenchmark │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P15_BuiltinStringTemplate │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P16_CustomTemplateProcessor1 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── PhoneProcessor.java ├── P16_CustomTemplateProcessor2 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── PhoneProcessor.java ├── P16_CustomTemplateProcessor3 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── PhoneProcessor.java ├── P16_CustomTemplateProcessor4 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P16_CustomTemplateProcessor5 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── PhoneProcessor.java ├── P17_LocaleOf │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P18_LocaleCurrency │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P18_LocaleOfLocalizedDate │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P19_UsingStrictfpClass │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── ScientificCalculator.java ├── P19_UsingStrictfpInterface │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── Rectangle.java ├── P19_UsingStrictfpInterfaceReflection │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── Rectangle.java ├── P20_MathAbsoluteValueOperationOverflow │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P21_MathQuotientOperationOverflow │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P22_ValueNextAlgebraicQuotient │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P23_GetDoubleParts │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P24_DoubleIsInteger │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── Numbers.java ├── P24_DoubleIsIntegerBenchmark │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P25_MultiplyHigh │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P26_FloorCeilModulus │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P27_CountPrimeNumbers │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── Primes.java ├── P27_PrimeFactors │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── Primes.java ├── P28_SquareRootBabylonian │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── Numbers.java ├── P29_RoundFloatNumber │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── Numbers.java ├── P30_ClampingBetweenMinMax │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── PressureRegulator.java ├── P31_MulitplyTwoIntegers │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── Numbers.java ├── P32_UsingTau │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P33_PRNGFindAll │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P33_PRNGFindByProperty │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P33_PRNGSelectViaOf │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P34_FillArrayRandomData │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P35_InfiniteStreamOfRndGenerators │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P36_LegacyRndFromRandomGenerator │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P37_ThreadSafeRandomGenerator │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java └── README.md ├── Chapter02 ├── P38_AsciiVsUnicode │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Charsets.java │ │ └── Main.java ├── P38_Emoji │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Charsets.java │ │ └── Main.java ├── P38_ReadingWritingFileUTF8 │ ├── README.md │ ├── chineseUTF16.txt │ ├── chineseUTF8.txt │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P38_StringToBinaryEncodings │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Charsets.java │ │ └── Main.java ├── P39_CheckIndexSubRangeZeroLength │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── NumberConverter.java │ │ └── Pipes.java ├── P40_StringIndentity │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── MyPoint.java ├── P41_UnamedClassesMain │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── HelloWorld.java ├── P42_SnippetsInJavadoc │ ├── README.md │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ ├── Main.java │ │ │ ├── Telemeter.java │ │ │ └── snippet-files │ │ │ └── MainSnippet.txt │ │ └── snippet-src │ │ ├── AtSnippet.txt │ │ ├── DistanceSnippet.java │ │ └── ParamDefaultSnippet.properties ├── P42_SnippetsInJavadocPreJDK18 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── Telemeter.java ├── P43_InvokeDefaultMethodsJDK16 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Book.java │ │ ├── Draft.java │ │ ├── Main.java │ │ ├── Printable.java │ │ └── Writable.java ├── P43_InvokeDefaultMethodsJDK8 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Book.java │ │ ├── Draft.java │ │ ├── Main.java │ │ ├── Printable.java │ │ └── Writable.java ├── P43_InvokeDefaultMethodsJDK9 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Book.java │ │ ├── Draft.java │ │ ├── Main.java │ │ ├── Printable.java │ │ └── Writable.java ├── P44_ByteToHexString │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Converters.java │ │ └── Main.java ├── P45_InnerClassesAndStatics │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── A.java │ │ ├── Main.java │ │ ├── NewConnection.java │ │ └── OldConnection.java ├── P46_AnonymousClassesAndStatics │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── Printer.java ├── P47_ErasureBridge │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── FunPuzzle.java │ │ ├── Main.java │ │ └── Puzzle.java ├── P47_ErasureGeneric │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P47_ErasureHeapPollution │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P47_ErasureVsOverloading │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── A.java │ │ ├── B.java │ │ └── Main.java ├── P47_PolymorphicOverloading │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P48_XlintDefaultConstructor │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ ├── modern │ │ └── challenge │ │ │ ├── House.java │ │ │ └── Main.java │ │ └── module-info.java ├── P49_ReceiverParameter │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Cashed.java │ │ ├── Delivered.java │ │ ├── Main.java │ │ ├── New.java │ │ ├── Ordered.java │ │ ├── Parcel.java │ │ ├── PaymentService.java │ │ ├── Person.java │ │ ├── Shipped.java │ │ ├── Truck.java │ │ └── ValidAddress.java ├── P50_ImmutableStack │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── ImmutableStack.java │ │ ├── Main.java │ │ └── Stack.java ├── P51_CommonStringMistake │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P52_Common5NPE │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── ChainSaw.java │ │ └── Main.java ├── P52_WorkingAroundNPE │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── ChainSaw.java │ │ └── Main.java ├── P53_YieldStatementBlocks │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── FootballPlayer.java │ │ ├── Main.java │ │ ├── Player.java │ │ ├── SnookerPlayer.java │ │ ├── TennisPlayer.java │ │ └── UnknownPlayerException.java ├── P53_YieldSwitchExpression │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── FootballPlayer.java │ │ ├── Main.java │ │ ├── Player.java │ │ ├── SnookerPlayer.java │ │ ├── TennisPlayer.java │ │ └── UnknownPlayerException.java ├── P54_CaseNullClauseInSwitch │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── FootballPlayer.java │ │ ├── Main.java │ │ ├── Player.java │ │ ├── SnookerPlayer.java │ │ ├── TennisPlayer.java │ │ └── UnknownPlayerException.java ├── P55_EqualOperatorVsEquals │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P56_ClassicInstanceof │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P58_TypePatternMatchingInstanceof │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Usb.java ├── P59_BindingVariableScopeInstanceof │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Usb.java ├── P60_RewritingEqualsTypePatternInstanceof │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── MyPointGenericNew.java │ │ ├── MyPointGenericOld.java │ │ ├── MyPointNew.java │ │ └── MyPointOld.java ├── P61_TypePatternInstanceofGenerics │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P62_TypePatternInstanceofStream │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P63_TypePatternMatchingSwitch │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Usb.java ├── P64_GuardedPatternsSwitch1 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── House.java ├── P64_GuardedPatternsSwitch1JDK17 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── House.java ├── P64_GuardedPatternsSwitch2 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Assess.java ├── P64_GuardedPatternsSwitch2JDK17 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Assess.java ├── P65_TypePatternSwitchDominance │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P66_CompletenessInSwitchJDK20 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P66_CompletenessInSwitchJDK21 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P67_UnconditionalPatterns │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java └── P67_UnconditionalPatternsJDK17 │ ├── README.md │ ├── pom.xml │ └── src │ └── main │ └── java │ └── modern │ └── challenge │ └── Main.java ├── Chapter03 ├── P68_PeriodOfTheDay │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── DateConverters.java │ │ └── Main.java ├── P69_DateToYearMonth │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── DateConverters.java │ │ └── Main.java ├── P70_IntToYearMonth │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── DateConverters.java │ │ └── Main.java ├── P71_YearWeekToDate │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── DateConverters.java │ │ └── Main.java ├── P72_LeapYear │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── DateCheckers.java │ │ └── Main.java ├── P73_QuarterOfDate │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── DateCheckers.java │ │ └── Main.java ├── P74_FirstLastDayOfQuarter │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── DateCheckers.java │ │ ├── Main.java │ │ └── Quarter.java ├── P75_MonthFromQuarter │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── DateCheckers.java │ │ └── Main.java ├── P76_PregnancyDueDateCalculator │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── DateCheckers.java │ │ └── Main.java ├── P77_Stopwatch │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── InstantStopwatch.java │ │ ├── Main.java │ │ ├── MillisStopwatch.java │ │ └── NanoStopwatch.java ├── P78_FromMidnightToNow │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P79_SplitDateInEqualIntervals │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── DateCheckers.java │ │ └── Main.java ├── P80_SystemUTCVsSystemDefaultZone │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P81_WeekDayName │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P82_FirstLastDayOfYear │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── DateCheckers.java │ │ └── Main.java ├── P83_FirstLastDayOfWeek │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── DateCheckers.java │ │ └── Main.java ├── P84_MiddleOfTheMonth │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── DateCheckers.java │ │ └── Main.java ├── P85_QuartersBetweenTwoDates │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── DateCheckers.java │ │ └── Main.java ├── P86_ConvertCalendarToLocalDateTime │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── DateConverters.java │ │ └── Main.java └── P87_WeeksBetweenTwoDates │ ├── README.md │ ├── pom.xml │ └── src │ └── main │ └── java │ └── modern │ └── challenge │ ├── DateCheckers.java │ └── Main.java ├── Chapter04 ├── P100_GenericRecords │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── ContainerRecord.java │ │ ├── EngineRecord.java │ │ ├── FruitRecord.java │ │ ├── Main.java │ │ └── MelonRecord.java ├── P101_UnconditionalPatternRecords │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── EggplantRecord.java │ │ ├── Fruit.java │ │ ├── Main.java │ │ ├── MelonRecord.java │ │ └── SeedRecord.java ├── P102_StrShortener │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Concat.java │ │ ├── Literal.java │ │ ├── Main.java │ │ ├── Str.java │ │ └── Variable.java ├── P103_UnamedVariables │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── Melon.java ├── P103_UnnamedPatternSwitch1 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Appointment.java │ │ ├── Doctor.java │ │ ├── Hospital.java │ │ ├── Main.java │ │ ├── Patient.java │ │ ├── Resident.java │ │ └── Staff.java ├── P103_UnnamedPatternSwitch2 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Car.java │ │ ├── DSLEngine.java │ │ ├── ESSEngine.java │ │ ├── EngineType.java │ │ ├── LPGEngine.java │ │ └── Main.java ├── P103_UnnamedPatternsInstanceof │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Appointment.java │ │ ├── Doctor.java │ │ ├── Hospital.java │ │ ├── Main.java │ │ ├── Patient.java │ │ ├── Resident.java │ │ └── Staff.java ├── P104_JavaRecordsDependencyInjection │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── modern │ │ │ └── challenge │ │ │ ├── MainApplication.java │ │ │ ├── controller │ │ │ └── BookstoreController.java │ │ │ ├── record │ │ │ ├── Author.java │ │ │ └── Book.java │ │ │ └── service │ │ │ └── BookstoreService.java │ │ └── resources │ │ └── application.properties ├── P104_JavaRecordsInConfigs │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── modern │ │ │ └── challenge │ │ │ ├── MainApplication.java │ │ │ ├── controller │ │ │ └── BookstoreController.java │ │ │ ├── record │ │ │ ├── Author.java │ │ │ ├── BestSellerConfig.java │ │ │ └── Book.java │ │ │ └── service │ │ │ └── BookstoreService.java │ │ └── resources │ │ └── application.properties ├── P104_JavaRecordsInControllers │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── modern │ │ │ └── challenge │ │ │ ├── MainApplication.java │ │ │ ├── controller │ │ │ └── BookstoreController.java │ │ │ ├── record │ │ │ ├── Author.java │ │ │ └── Book.java │ │ │ └── service │ │ │ └── BookstoreService.java │ │ └── resources │ │ └── application.properties ├── P104_JavaRecordsInTemplates │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── modern │ │ │ └── challenge │ │ │ ├── MainApplication.java │ │ │ ├── controller │ │ │ └── BookstoreController.java │ │ │ ├── record │ │ │ ├── Author.java │ │ │ └── Book.java │ │ │ └── service │ │ │ └── BookstoreService.java │ │ └── resources │ │ ├── application.properties │ │ └── templates │ │ └── bookstore.html ├── P105_DtoRecordConstructor │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── bookstore │ │ │ ├── MainApplication.java │ │ │ ├── dto │ │ │ └── AuthorDto.java │ │ │ ├── entity │ │ │ └── Author.java │ │ │ ├── repository │ │ │ └── AuthorRepository.java │ │ │ └── service │ │ │ └── BookstoreService.java │ │ └── resources │ │ ├── application.properties │ │ └── data.sql ├── P105_DtoRecordConstructorExpression │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── bookstore │ │ │ ├── MainApplication.java │ │ │ ├── dto │ │ │ └── AuthorDto.java │ │ │ ├── entity │ │ │ └── Author.java │ │ │ ├── repository │ │ │ └── AuthorRepository.java │ │ │ └── service │ │ │ └── BookstoreService.java │ │ └── resources │ │ ├── application.properties │ │ └── data.sql ├── P105_DtoRecordJbcTemplate │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── bookstore │ │ │ ├── MainApplication.java │ │ │ ├── jdbcTemplate │ │ │ └── dto │ │ │ │ ├── AuthorDto.java │ │ │ │ ├── AuthorExtractor.java │ │ │ │ └── BookDto.java │ │ │ └── service │ │ │ └── BookstoreService.java │ │ └── resources │ │ ├── application.properties │ │ ├── data.sql │ │ └── schema.sql ├── P105_DtoRecordResultTransformer │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── bookstore │ │ │ ├── MainApplication.java │ │ │ ├── dao │ │ │ ├── AuthorDao.java │ │ │ └── Dao.java │ │ │ ├── dto │ │ │ ├── AuthorDto.java │ │ │ └── BookDto.java │ │ │ ├── entity │ │ │ ├── Author.java │ │ │ └── Book.java │ │ │ ├── service │ │ │ └── BookstoreService.java │ │ │ └── transformer │ │ │ └── AuthorBookTransformer.java │ │ └── resources │ │ ├── application.properties │ │ └── data.sql ├── P105_RecordAndEmbeddables │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── bookstore │ │ │ ├── MainApplication.java │ │ │ ├── dto │ │ │ └── AuthorDto.java │ │ │ ├── embeddable │ │ │ └── Contact.java │ │ │ ├── entity │ │ │ └── Author.java │ │ │ ├── repository │ │ │ └── AuthorRepository.java │ │ │ └── service │ │ │ └── BookstoreService.java │ │ └── resources │ │ ├── application.properties │ │ └── data.sql ├── P106_RecordAndjOOQMultiset │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── classicmodels │ │ │ ├── MainApplication.java │ │ │ ├── dto │ │ │ ├── RecordManager.java │ │ │ ├── RecordOffice.java │ │ │ ├── RecordProduct.java │ │ │ └── RecordProductLine.java │ │ │ ├── repository │ │ │ └── ClassicModelsRepository.java │ │ │ └── service │ │ │ └── ClassicModelsService.java │ │ └── resources │ │ └── application.properties ├── P106_RecordAndjOOQMultisetAgg │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── classicmodels │ │ │ ├── MainApplication.java │ │ │ ├── dto │ │ │ ├── RecordManager.java │ │ │ ├── RecordOffice.java │ │ │ ├── RecordProduct.java │ │ │ └── RecordProductLine.java │ │ │ ├── repository │ │ │ └── ClassicModelsRepository.java │ │ │ └── service │ │ │ └── ClassicModelsService.java │ │ └── resources │ │ └── application.properties ├── P106_SQL │ └── mysql │ │ ├── V1.1__Create.sql │ │ └── afterMigrate.sql ├── P88_SimpleRecord │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── Melon.java │ │ └── MelonRecord.java ├── P89_RecordCanonicalCntr │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── MarketRecord.java │ │ └── MelonRecord.java ├── P90_EnrichedRecord │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── MelonRecord.java ├── P92_RecordMultipleCntrs │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── MelonRecord.java ├── P93_RecordAndInterfaces │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── MelonRecord.java │ │ └── PestInspector.java ├── P94_RecordSerialization │ ├── README.md │ ├── object.data │ ├── object_malicious.data │ ├── object_record.data │ ├── object_record_malicious.data │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── Melon.java │ │ ├── MelonContainer.java │ │ ├── MelonContainerRecord.java │ │ └── MelonRecord.java ├── P94_RefactoringSerialization │ ├── README.md │ ├── object.data │ ├── object_malicious.data │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── Melon.java │ │ ├── MelonContainer.java │ │ ├── MelonContainerRecord.java │ │ └── MelonRecord.java ├── P95_RecordCanonicalCntrReflection │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── MelonMarketRecord.java │ │ ├── MelonRecord.java │ │ └── Records.java ├── P96_UsingRecordsInStreams │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── MelonRecord.java │ │ └── WeightsAndTotalRecord.java ├── P97_RecordPatternInstanceof │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Appointment.java │ │ ├── Doctor.java │ │ ├── Hospital.java │ │ ├── Main.java │ │ ├── Patient.java │ │ ├── Resident.java │ │ └── Staff.java ├── P98_RecordPatternSwitch │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Appointment.java │ │ ├── Doctor.java │ │ ├── Hospital.java │ │ ├── Main.java │ │ ├── Patient.java │ │ ├── Resident.java │ │ └── Staff.java ├── P99_RecordPatternInstanceofGuarded │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Appointment.java │ │ ├── Doctor.java │ │ ├── Hospital.java │ │ ├── Main.java │ │ ├── Patient.java │ │ ├── Resident.java │ │ └── Staff.java └── P99_RecordPatternSwitchGuarded │ ├── README.md │ ├── pom.xml │ └── src │ └── main │ └── java │ └── modern │ └── challenge │ ├── Appointment.java │ ├── Doctor.java │ ├── Hospital.java │ ├── Main.java │ ├── Patient.java │ ├── Resident.java │ └── Staff.java ├── Chapter05 ├── P108_VectorTerminology │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ ├── modern │ │ └── challenge │ │ │ └── Main.java │ │ └── module-info.java ├── P109_SimpleSummingArrays │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ ├── modern │ │ └── challenge │ │ │ └── Main.java │ │ └── module-info.java ├── P109_SummingArrays │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ ├── modern │ │ └── challenge │ │ │ └── Main.java │ │ └── module-info.java ├── P110_SummingArraysUnrolled │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ ├── modern │ │ └── challenge │ │ │ └── Main.java │ │ └── module-info.java ├── P111_BenchmarkVectors │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ ├── modern │ │ └── challenge │ │ │ └── Main.java │ │ └── module-info.java ├── P112_VectorApiAndFma │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ ├── modern │ │ └── challenge │ │ │ └── Main.java │ │ └── module-info.java ├── P113_MultiplyingMatricesVectorApi │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ ├── modern │ │ └── challenge │ │ │ └── Main.java │ │ └── module-info.java ├── P114_NegativeEffectVectorApi │ ├── README.md │ ├── image.png │ ├── image_negative.png │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ ├── modern │ │ └── challenge │ │ │ └── Main.java │ │ └── module-info.java ├── P115_FactoryMethodsForCollections │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P116_StreamToList │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── MelonMarket.java │ │ └── MelonRecord.java ├── P117_newHashMap │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P118_SequencedCollectionsAddFirstLast │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P118_SequencedCollectionsGetFirstLast │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P118_SequencedCollectionsRemove │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P118_SequencedCollectionsReverse │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P119_TheRopeDS │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── Rope.java ├── P120_TheSkipListDS │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── SkipList.java ├── P121_TheKDTreeDS │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── KdTree.java │ │ └── Main.java ├── P122_TheZipperDS │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── tree │ │ └── Node.java │ │ └── zipper │ │ ├── Cursor.java │ │ ├── ZipNode.java │ │ ├── Zippable.java │ │ ├── Zipper.java │ │ └── ZipperRange.java ├── P123_TheBinomialHeapDS │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── BinomialHeap.java │ │ └── Main.java ├── P124_TheFibonacciHeapDS │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── FibonacciHeap.java │ │ └── Main.java ├── P125_ThePairingHeapDS │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── PairHeap.java ├── P126_TheHuffmanCodingDS │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Huffman.java │ │ └── Main.java ├── P127_TheSplayTreeDS │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── SplayTree.java ├── P128_TheIntervalTreeDS │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── IntervalTree.java │ │ └── Main.java ├── P129_TheUnrolledLinkedListDS_1 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── UnrolledLinkedList.java ├── P129_TheUnrolledLinkedListDS_2 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── UnrolledLinkedList.java └── P130_TheJoinAlgorithms │ ├── README.md │ ├── pom.xml │ └── src │ └── main │ └── java │ └── modern │ └── challenge │ ├── Author.java │ ├── Book.java │ ├── Joins.java │ ├── Main.java │ └── ResultRow.java ├── Chapter06 ├── P131_ObjectToByteArraySer │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Converters.java │ │ ├── Main.java │ │ └── Melon.java ├── P132_ObjectToStringSer │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Converters.java │ │ ├── Main.java │ │ └── Melon.java ├── P133_ObjectToXML │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Converters.java │ │ ├── Main.java │ │ └── Melon.java ├── P135_PatternBasedStreamGlobalFilter │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Converters.java │ │ ├── Main.java │ │ └── Melon.java ├── P135_PatternBasedStreamSpecificFilter │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Converters.java │ │ ├── Main.java │ │ └── Melon.java ├── P136_CustomClassFilter │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Converters.java │ │ ├── Main.java │ │ ├── Melon.java │ │ └── MelonFilter.java ├── P137_CustomMethodFilter1 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Converters.java │ │ ├── Filters.java │ │ ├── Main.java │ │ └── Melon.java ├── P137_CustomMethodFilter2 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Cantaloupe.java │ │ ├── Converters.java │ │ ├── Filters.java │ │ ├── Main.java │ │ ├── Melon.java │ │ ├── Muskmelons.java │ │ └── Pumpkin.java ├── P138_CustomLambdaFilter │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Converters.java │ │ ├── Main.java │ │ └── Melon.java ├── P139_DeserializationStackOverflowError │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Converters.java │ │ └── Main.java ├── P140_DeserializationDoS │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Converters.java │ │ └── Main.java ├── P141_JDK17CustomFilter │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Cantaloupe.java │ │ ├── Converters.java │ │ ├── Filters.java │ │ ├── HoneyDew.java │ │ ├── Main.java │ │ ├── Melon.java │ │ ├── Muskmelon.java │ │ ├── Persian.java │ │ └── Pumpkin.java ├── P142_JDK17CustomFilterFactory │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Cantaloupe.java │ │ ├── Converters.java │ │ ├── Filters.java │ │ ├── HoneyDew.java │ │ ├── Main.java │ │ ├── Melon.java │ │ ├── MelonFilterFactory.java │ │ ├── Muskmelon.java │ │ ├── Persian.java │ │ └── Pumpkin.java └── P143_MonitoringDeserializationJfr │ ├── README.md │ ├── deserializationEvent.jfc │ ├── pom.xml │ ├── recording.jfr │ └── src │ └── main │ └── java │ └── modern │ └── challenge │ ├── Converters.java │ ├── Main.java │ └── Melon.java ├── Chapter07 ├── JDK 20 │ ├── P144_EngagingJNI │ │ ├── README.md │ │ ├── jni │ │ │ └── cpp │ │ │ │ ├── math.dll │ │ │ │ └── modern_challenge_Main.o │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ ├── Main.java │ │ │ └── cpp │ │ │ ├── modern_challenge_Main.cpp │ │ │ └── modern_challenge_Main.h │ ├── P145_EngagingJNA │ │ ├── README.md │ │ ├── jna │ │ │ └── cpp │ │ │ │ ├── Arithmetic.o │ │ │ │ └── math.dll │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ ├── Main.java │ │ │ ├── SimpleMath.java │ │ │ └── cpp │ │ │ ├── Arithmetic.cpp │ │ │ └── Arithmetic.h │ ├── P146_EngagingJNR │ │ ├── README.md │ │ ├── jnr │ │ │ └── cpp │ │ │ │ ├── Arithmetic.o │ │ │ │ └── math.dll │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ ├── Main.java │ │ │ ├── SimpleMath.java │ │ │ └── cpp │ │ │ ├── Arithmetic.cpp │ │ │ └── Arithmetic.h │ ├── P149_ArenaMemorySegment │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P150_MemorySegmentAndArray │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ ├── modern │ │ │ └── challenge │ │ │ │ └── Main.java │ │ │ └── module-info.java │ ├── P151_MemorySegmentAndAddress │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P152_IntroSequenceLayout │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P153_MemorySegmentAndStruct │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P154_MemorySegmentAndUnion │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P155_IntroPaddingLayout │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P156_CopyingSlicingMemorySegments │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ ├── modern │ │ │ └── challenge │ │ │ │ └── Main.java │ │ │ └── module-info.java │ ├── P157_WorkingWithSlicingAllocator │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P158_IntroSliceHandle │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P159_IntroLayoutFlatenning │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P160_IntroLayoutReshaping │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P161_IntroLayoutSpreader │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P162_IntroMemorySegmentViewVarHandle │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P163_StreamingMemorySegment │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P164_ArenaMappedMemorySegment │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ ├── Main.java │ │ │ └── MappedArena.java │ ├── P164_MappedMemorySegment │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P165_CallingGetpid │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P166_CallingSumTwoInt │ │ ├── README.md │ │ ├── lib │ │ │ └── cpp │ │ │ │ ├── Arithmetic.o │ │ │ │ └── math.dll │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ ├── Main.java │ │ │ └── cpp │ │ │ ├── Arithmetic.cpp │ │ │ └── Arithmetic.h │ ├── P167_CallingModf │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P168_CallingStrcat │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P169_CallingBsearch │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ └── P171_JextractAndModf │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ └── main │ │ └── java │ │ ├── c │ │ └── lib │ │ │ └── math │ │ │ ├── Constants$root.java │ │ │ ├── RuntimeHelper.java │ │ │ ├── constants$0.java │ │ │ └── math_h.java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── JDK 21 │ ├── P144_EngagingJNI │ │ ├── README.md │ │ ├── jni │ │ │ └── cpp │ │ │ │ ├── math.dll │ │ │ │ └── modern_challenge_Main.o │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ ├── Main.java │ │ │ └── cpp │ │ │ ├── modern_challenge_Main.cpp │ │ │ └── modern_challenge_Main.h │ ├── P145_EngagingJNA │ │ ├── README.md │ │ ├── jna │ │ │ └── cpp │ │ │ │ ├── Arithmetic.o │ │ │ │ └── math.dll │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ ├── Main.java │ │ │ ├── SimpleMath.java │ │ │ └── cpp │ │ │ ├── Arithmetic.cpp │ │ │ └── Arithmetic.h │ ├── P146_EngagingJNR │ │ ├── README.md │ │ ├── jnr │ │ │ └── cpp │ │ │ │ ├── Arithmetic.o │ │ │ │ └── math.dll │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ ├── Main.java │ │ │ ├── SimpleMath.java │ │ │ └── cpp │ │ │ ├── Arithmetic.cpp │ │ │ └── Arithmetic.h │ ├── P149_ArenaMemorySegment │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P150_MemorySegmentAndArray │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ ├── modern │ │ │ └── challenge │ │ │ │ └── Main.java │ │ │ └── module-info.java │ ├── P151_MemorySegmentAndAddress │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P152_IntroSequenceLayout │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P153_MemorySegmentAndStruct │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P154_MemorySegmentAndUnion │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P155_IntroPaddingLayout │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P156_CopyingSlicingMemorySegments │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ ├── modern │ │ │ └── challenge │ │ │ │ └── Main.java │ │ │ └── module-info.java │ ├── P157_WorkingWithSlicingAllocator │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P158_IntroSliceHandle │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P159_IntroLayoutFlatenning │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P160_IntroLayoutReshaping │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P161_IntroLayoutSpreader │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P162_IntroMemorySegmentViewVarHandle │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P163_StreamingMemorySegment │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P164_ArenaMappedMemorySegment │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ ├── Main.java │ │ │ └── MappedArena.java │ ├── P164_MappedMemorySegment │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P165_CallingGetpid │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P166_CallingSumTwoInt │ │ ├── README.md │ │ ├── lib │ │ │ └── cpp │ │ │ │ ├── Arithmetic.o │ │ │ │ └── math.dll │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ ├── Main.java │ │ │ └── cpp │ │ │ ├── Arithmetic.cpp │ │ │ └── Arithmetic.h │ ├── P167_CallingModf │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P168_CallingStrcat │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ ├── P169_CallingBsearch │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ └── P171_JextractAndModf │ │ ├── README.md │ │ ├── includes.txt │ │ ├── pom.xml │ │ └── src │ │ └── main │ │ └── java │ │ ├── c │ │ └── lib │ │ │ └── math │ │ │ ├── LC_ID.java │ │ │ ├── RuntimeHelper.java │ │ │ ├── __mingw_dbl_type_t.java │ │ │ ├── __mingw_flt_type_t.java │ │ │ ├── __mingw_fp_types_t.java │ │ │ ├── __mingw_ldbl_type_t.java │ │ │ ├── __mingw_setusermatherr$x0.java │ │ │ ├── __setusermatherr$x0.java │ │ │ ├── _complex.java │ │ │ ├── _exception.java │ │ │ ├── _locale_tstruct.java │ │ │ ├── constants$0.java │ │ │ ├── constants$1.java │ │ │ ├── constants$10.java │ │ │ ├── constants$11.java │ │ │ ├── constants$12.java │ │ │ ├── constants$13.java │ │ │ ├── constants$14.java │ │ │ ├── constants$15.java │ │ │ ├── constants$16.java │ │ │ ├── constants$17.java │ │ │ ├── constants$18.java │ │ │ ├── constants$19.java │ │ │ ├── constants$2.java │ │ │ ├── constants$20.java │ │ │ ├── constants$21.java │ │ │ ├── constants$22.java │ │ │ ├── constants$23.java │ │ │ ├── constants$24.java │ │ │ ├── constants$25.java │ │ │ ├── constants$26.java │ │ │ ├── constants$27.java │ │ │ ├── constants$28.java │ │ │ ├── constants$29.java │ │ │ ├── constants$3.java │ │ │ ├── constants$30.java │ │ │ ├── constants$31.java │ │ │ ├── constants$32.java │ │ │ ├── constants$33.java │ │ │ ├── constants$34.java │ │ │ ├── constants$35.java │ │ │ ├── constants$36.java │ │ │ ├── constants$37.java │ │ │ ├── constants$38.java │ │ │ ├── constants$39.java │ │ │ ├── constants$4.java │ │ │ ├── constants$40.java │ │ │ ├── constants$41.java │ │ │ ├── constants$42.java │ │ │ ├── constants$43.java │ │ │ ├── constants$44.java │ │ │ ├── constants$45.java │ │ │ ├── constants$46.java │ │ │ ├── constants$47.java │ │ │ ├── constants$48.java │ │ │ ├── constants$49.java │ │ │ ├── constants$5.java │ │ │ ├── constants$50.java │ │ │ ├── constants$51.java │ │ │ ├── constants$52.java │ │ │ ├── constants$53.java │ │ │ ├── constants$6.java │ │ │ ├── constants$7.java │ │ │ ├── constants$8.java │ │ │ ├── constants$9.java │ │ │ ├── localeinfo_struct.java │ │ │ ├── math_h.java │ │ │ ├── tagLC_ID.java │ │ │ ├── threadlocaleinfostruct.java │ │ │ └── threadlocinfo.java │ │ └── modern │ │ └── challenge │ │ └── Main.java └── JDK 22 │ ├── P144_EngagingJNI │ ├── README.md │ ├── jni │ │ └── cpp │ │ │ ├── math.dll │ │ │ └── modern_challenge_Main.o │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── cpp │ │ ├── modern_challenge_Main.cpp │ │ └── modern_challenge_Main.h │ ├── P145_EngagingJNA │ ├── README.md │ ├── jna │ │ └── cpp │ │ │ ├── Arithmetic.o │ │ │ └── math.dll │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── SimpleMath.java │ │ └── cpp │ │ ├── Arithmetic.cpp │ │ └── Arithmetic.h │ ├── P146_EngagingJNR │ ├── README.md │ ├── jnr │ │ └── cpp │ │ │ ├── Arithmetic.o │ │ │ └── math.dll │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── SimpleMath.java │ │ └── cpp │ │ ├── Arithmetic.cpp │ │ └── Arithmetic.h │ ├── P149_ArenaMemorySegment │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java │ ├── P150_MemorySegmentAndArray │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ ├── modern │ │ └── challenge │ │ │ └── Main.java │ │ └── module-info.java │ ├── P151_MemorySegmentAndAddress │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java │ ├── P152_IntroSequenceLayout │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java │ ├── P153_MemorySegmentAndStruct │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java │ ├── P154_MemorySegmentAndUnion │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java │ ├── P155_IntroPaddingLayout │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java │ ├── P156_CopyingSlicingMemorySegments │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ ├── modern │ │ └── challenge │ │ │ └── Main.java │ │ └── module-info.java │ ├── P157_WorkingWithSlicingAllocator │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java │ ├── P158_IntroSliceHandle │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java │ ├── P159_IntroLayoutFlatenning │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java │ ├── P160_IntroLayoutReshaping │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java │ ├── P161_IntroLayoutSpreader │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java │ ├── P162_IntroMemorySegmentViewVarHandle │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java │ ├── P163_StreamingMemorySegment │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java │ ├── P164_ArenaMappedMemorySegment │ ├── README.md │ ├── pom.xml │ ├── readme1712836518222.txt │ ├── readme1712836518277.txt │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── MappedArena.java │ ├── P164_MappedMemorySegment │ ├── README.md │ ├── pom.xml │ ├── readme.txt │ ├── sparse_readme.txt │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java │ ├── P165_CallingGetpid │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java │ ├── P166_CallingSumTwoInt │ ├── README.md │ ├── lib │ │ └── cpp │ │ │ ├── Arithmetic.o │ │ │ └── math.dll │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── cpp │ │ ├── Arithmetic.cpp │ │ └── Arithmetic.h │ ├── P167_CallingModf │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java │ └── P168_CallingStrcat │ ├── README.md │ ├── pom.xml │ └── src │ └── main │ └── java │ └── modern │ └── challenge │ └── Main.java ├── Chapter08 ├── P172_ElectricPanelHierarchy │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ ├── challenge │ │ └── client │ │ │ └── Main.java │ │ └── circuit │ │ ├── ElectricComponent.java │ │ ├── capacitor │ │ ├── Capacitor.java │ │ ├── CeramicCapacitor.java │ │ └── ElectrolyticCapacitor.java │ │ ├── panel │ │ ├── ElectricBreaker.java │ │ └── ElectricPanel.java │ │ ├── resistor │ │ ├── CarbonResistor.java │ │ ├── MetalFilmResistor.java │ │ ├── MetalOxideResistor.java │ │ ├── MetalResistor.java │ │ └── Resistor.java │ │ ├── transistor │ │ ├── BipolarTransistor.java │ │ ├── FieldEffectTransistor.java │ │ └── Transistor.java │ │ └── type │ │ ├── ElectricCircuit.java │ │ ├── ParallelCircuit.java │ │ ├── SeriesCircuit.java │ │ └── ShortCircuit.java ├── P173_ClosedElectricPanelHierarchy │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ ├── challenge │ │ └── client │ │ │ └── Main.java │ │ └── circuit │ │ ├── ElectricComponent.java │ │ ├── capacitor │ │ ├── Capacitor.java │ │ ├── CeramicCapacitor.java │ │ └── ElectrolyticCapacitor.java │ │ ├── panel │ │ ├── ElectricBreaker.java │ │ └── ElectricPanel.java │ │ ├── resistor │ │ ├── CarbonResistor.java │ │ ├── MetalFilmResistor.java │ │ ├── MetalOxideResistor.java │ │ ├── MetalResistor.java │ │ └── Resistor.java │ │ ├── transistor │ │ ├── BipolarTransistor.java │ │ ├── FieldEffectTransistor.java │ │ └── Transistor.java │ │ └── type │ │ ├── ElectricCircuit.java │ │ ├── ParallelCircuit.java │ │ ├── SeriesCircuit.java │ │ └── ShortCircuit.java ├── P174_SealedHierarchySameSourceFile │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ ├── com │ │ ├── melon │ │ │ └── co │ │ │ │ └── Melon.java │ │ ├── refinery │ │ │ └── fuel │ │ │ │ └── Fuel.java │ │ └── truck │ │ │ └── co │ │ │ └── Truck.java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P175_SealedHierarchySeparatePackages │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ ├── com │ │ ├── rafinery │ │ │ └── fuel │ │ │ │ └── type │ │ │ │ ├── GaseousFuel.java │ │ │ │ ├── LiquidFuel.java │ │ │ │ └── SolidFuel.java │ │ └── refinery │ │ │ ├── fuel │ │ │ └── Fuel.java │ │ │ ├── gaseousfuel │ │ │ ├── Chloromethane.java │ │ │ ├── Dichloromethane.java │ │ │ ├── Hydrogen.java │ │ │ ├── Methane.java │ │ │ ├── NaturalGas.java │ │ │ ├── Propane.java │ │ │ └── Trichloromethane.java │ │ │ ├── liquidfuel │ │ │ ├── Diesel.java │ │ │ ├── Ethanol.java │ │ │ ├── Gasoline.java │ │ │ └── Petroleum.java │ │ │ └── solidfuel │ │ │ ├── Charcoal.java │ │ │ └── Coke.java │ │ ├── modern │ │ └── challenge │ │ │ └── Main.java │ │ └── module-info.java ├── P175_SealedHierarchySeparateSources │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ ├── com │ │ └── refinery │ │ │ └── fuel │ │ │ ├── Charcoal.java │ │ │ ├── Chloromethane.java │ │ │ ├── Coke.java │ │ │ ├── Dichloromethane.java │ │ │ ├── Diesel.java │ │ │ ├── Ethanol.java │ │ │ ├── Fuel.java │ │ │ ├── GaseousFuel.java │ │ │ ├── Gasoline.java │ │ │ ├── Hydrogen.java │ │ │ ├── LiquidFuel.java │ │ │ ├── Methane.java │ │ │ ├── NaturalGas.java │ │ │ ├── Petroleum.java │ │ │ ├── Propane.java │ │ │ ├── SolidFuel.java │ │ │ └── Trichloromethane.java │ │ ├── modern │ │ └── challenge │ │ │ └── Main.java │ │ └── rafinery │ │ └── sealed │ │ └── one │ │ └── file │ │ └── Fuel.java ├── P176_SealedElectricPanelHierarchy │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ ├── modern │ │ ├── challenge │ │ │ └── client │ │ │ │ └── Main.java │ │ └── circuit │ │ │ ├── ElectricComponent.java │ │ │ ├── capacitor │ │ │ ├── Capacitor.java │ │ │ ├── CeramicCapacitor.java │ │ │ └── ElectrolyticCapacitor.java │ │ │ ├── panel │ │ │ ├── ElectricBreaker.java │ │ │ └── ElectricPanel.java │ │ │ ├── resistor │ │ │ ├── CarbonResistor.java │ │ │ ├── MetalFilmResistor.java │ │ │ ├── MetalOxideResistor.java │ │ │ ├── MetalResistor.java │ │ │ └── Resistor.java │ │ │ ├── transistor │ │ │ ├── BipolarTransistor.java │ │ │ ├── FieldEffectTransistor.java │ │ │ └── Transistor.java │ │ │ └── type │ │ │ ├── ElectricCircuit.java │ │ │ ├── ParallelCircuit.java │ │ │ ├── SeriesCircuit.java │ │ │ └── ShortCircuit.java │ │ └── module-info.java ├── P177_SealedFuelHierarchyWithRecords │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ ├── com │ │ └── refinery │ │ │ └── fuel │ │ │ ├── Charcoal.java │ │ │ ├── Chloromethane.java │ │ │ ├── Coke.java │ │ │ ├── Dichloromethane.java │ │ │ ├── Diesel.java │ │ │ ├── Ethanol.java │ │ │ ├── Fuel.java │ │ │ ├── GaseousFuel.java │ │ │ ├── Gasoline.java │ │ │ ├── Hydrogen.java │ │ │ ├── LiquidFuel.java │ │ │ ├── Methane.java │ │ │ ├── NaturalGas.java │ │ │ ├── Petroleum.java │ │ │ ├── Propane.java │ │ │ ├── SolidFuel.java │ │ │ └── Trichloromethane.java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P178_SealedClassesCastConvInstanceof1 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── Quadrilateral.java │ │ ├── Rectangle.java │ │ └── Triangle.java ├── P178_SealedClassesCastConvInstanceof2 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── Quadrilateral.java │ │ ├── Rectangle.java │ │ └── Triangle.java ├── P178_SealedClassesCastConvInstanceof3 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── Quadrilateral.java │ │ ├── Rectangle.java │ │ └── Triangle.java ├── P179_SealedClassesAndSwitch │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── TextConverter.java │ │ ├── Utf16.java │ │ ├── Utf16be.java │ │ ├── Utf16le.java │ │ ├── Utf32.java │ │ └── Utf8.java ├── P179_SealedClassesSwitchBinTree │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P180_SealedClassesAndVisitorPattern1 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Capacitor.java │ │ ├── ElectricCircuit.java │ │ ├── ElectricComponent.java │ │ ├── ElectricComponentVisitor.java │ │ ├── Main.java │ │ ├── Resistor.java │ │ ├── Transistor.java │ │ └── XmlExportVisitor.java ├── P180_SealedClassesAndVisitorPattern2 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Capacitor.java │ │ ├── ElectricCircuit.java │ │ ├── ElectricComponent.java │ │ ├── Main.java │ │ ├── Resistor.java │ │ └── Transistor.java ├── P181_SealedClassesAndReflection │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ ├── com │ │ └── refinery │ │ │ └── fuel │ │ │ ├── Charcoal.java │ │ │ ├── Chloromethane.java │ │ │ ├── Coke.java │ │ │ ├── Dichloromethane.java │ │ │ ├── Diesel.java │ │ │ ├── Ethanol.java │ │ │ ├── Fuel.java │ │ │ ├── GaseousFuel.java │ │ │ ├── Gasoline.java │ │ │ ├── Hydrogen.java │ │ │ ├── LiquidFuel.java │ │ │ ├── Methane.java │ │ │ ├── NaturalGas.java │ │ │ ├── Petroleum.java │ │ │ ├── Propane.java │ │ │ ├── SolidFuel.java │ │ │ └── Trichloromethane.java │ │ └── modern │ │ ├── challenge │ │ └── Main.java │ │ └── reflection │ │ └── Inspector.java └── P184_HiddenClasses │ ├── README.md │ ├── pom.xml │ └── src │ └── main │ └── java │ └── modern │ └── challenge │ ├── InternalMath.java │ ├── Main.java │ └── Math.java ├── Chapter09 ├── P185_MapMulti1 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P185_MapMulti2 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Author.java │ │ ├── Book.java │ │ ├── Bookshelf.java │ │ └── Main.java ├── P186_StreamMapCustomMap │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── Post.java ├── P187_LambdaVsMethodReference │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── Print.java │ │ └── Printer.java ├── P188_LambdaLaziness │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P189_LambdaLazinessDysfunctional │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── ApplicationDependency.java │ │ ├── DependencyManager.java │ │ └── Main.java ├── P189_LambdaLazinessFunctional │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── ApplicationDependency.java │ │ ├── DependencyManager.java │ │ ├── FSupplier.java │ │ ├── Main.java │ │ └── Memoize.java ├── P189_LambdaLazinessImperative │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── ApplicationDependency.java │ │ ├── DependencyManager.java │ │ └── Main.java ├── P190_StringToArrayOfType │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P191_ApplyMultiplePredicates │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Car.java │ │ ├── Main.java │ │ └── Predicates.java ├── P192_FilterNestedCollection │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Author.java │ │ ├── Book.java │ │ └── Main.java ├── P193_UsingBiPredicate │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Car.java │ │ └── Main.java ├── P194_BuildCustomPredicate │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Car.java │ │ ├── Main.java │ │ └── PredicateBuilder.java ├── P195_BuildCustomPredicateMap │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Car.java │ │ ├── Main.java │ │ └── PredicateBuilder.java ├── P196_LoggingPredicate │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Car.java │ │ ├── LogPredicate.java │ │ ├── Main.java │ │ └── Predicates.java ├── P197_ImplementingContainsAllAny1 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Car.java │ │ ├── Main.java │ │ ├── Streams.java │ │ └── StreamsWrapper.java ├── P197_ImplementingContainsAllAny2 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Car.java │ │ ├── Main.java │ │ └── Streams.java ├── P198_ImplementingRemoveRetainAll1 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Car.java │ │ ├── Main.java │ │ ├── Streams.java │ │ └── StreamsWrapper.java ├── P198_ImplementingRemoveRetainAll2 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Car.java │ │ ├── Main.java │ │ └── Streams.java ├── P199_StreamComparators │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Car.java │ │ └── Main.java ├── P200_CustomSortedComparator │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Car.java │ │ └── Main.java ├── P201_FilteringMap │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Car.java │ │ ├── Filters.java │ │ └── Main.java ├── P202_CustomCollectorOf │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Car.java │ │ ├── Main.java │ │ ├── MyCollectors.java │ │ ├── SplayTree.java │ │ ├── Submersible.java │ │ └── Vehicle.java ├── P203_StreamAndCheckedException │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Exceptions.java │ │ └── Main.java ├── P204_StreamDistinctBy │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Car.java │ │ ├── Main.java │ │ └── Streams.java ├── P205_CollectorSkipKeepItems │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Car.java │ │ ├── Main.java │ │ └── MyCollectors.java ├── P206_FunctionWith5Args │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── FiveFunction.java │ │ ├── Logistics.java │ │ ├── Main.java │ │ └── PL4.java ├── P207_ConsumerWith5Args │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── FiveConsumer.java │ │ ├── Logistics.java │ │ └── Main.java └── P208_FunctionApplyOnly │ ├── README.md │ ├── pom.xml │ └── src │ └── main │ └── java │ └── modern │ └── challenge │ ├── Main.java │ └── TriFunction.java ├── Chapter10 ├── P210_UnstructuredConcurrencySample │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── TestingTeam.java │ │ └── UserNotFoundException.java ├── P211_HowManyThreadsCreate │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P211_IntroCheckVirtualThread │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P211_IntroStartVirtualThread │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P211_IntroStartVirtualThreadBuilder │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P211_IntroUnstartedVirtualThread │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P211_IntroVirtualThreadFactory │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P212_IntroNewVirtualThreadPerTaskExecutor │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P213_VirtualThreadForkJoinPool │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P214_VirtualThreadsAndSyncCode1 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P214_VirtualThreadsAndSyncCode2 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P215_ContextSwitching1 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P215_ContextSwitching2 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P215_ContextSwitching3 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P216_NewVirtualThreadPerTaskExecutorInvokeAllAny │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P217_InvokeAllOnSuccess │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── TestingTeam.java │ │ └── UserNotFoundException.java ├── P217_InvokeAnyOnSuccess │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── TestingTeam.java │ │ └── UserNotFoundException.java ├── P218_HookingTaskState │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── TestingTeam.java │ │ └── UserNotFoundException.java ├── P219_NewVirtualThreadPerTaskExecutorStream1 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P219_NewVirtualThreadPerTaskExecutorStream2 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P220_IntroStructuredTaskScope │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── TestingTeam.java │ │ └── UserNotFoundException.java ├── P221_IntroStructuredTaskScopeOnSuccess1 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── TestingTeam.java │ │ └── UserNotFoundException.java ├── P221_IntroStructuredTaskScopeOnSuccess2 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── TestingTeam.java │ │ └── UserNotFoundException.java ├── P222_IntroStructuredTaskScopeOnFailure1 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── TestingTeam.java │ │ └── UserNotFoundException.java ├── P222_IntroStructuredTaskScopeOnFailure2 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── TestingTeam.java │ │ └── UserNotFoundException.java ├── P223_StructuredTaskScopeStream1 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── TestingTeam.java │ │ └── UserNotFoundException.java ├── P223_StructuredTaskScopeStream2 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── TestingTeam.java │ │ └── UserNotFoundException.java ├── P224_MonitoringVirtualThreadsJfr1 │ ├── README.md │ ├── pom.xml │ ├── recording.jfr │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ ├── Main.java │ │ │ ├── TestingTeam.java │ │ │ └── UserNotFoundException.java │ └── vtEvent.jfc ├── P224_MonitoringVirtualThreadsJfr2 │ ├── README.md │ ├── pom.xml │ ├── recording.jfr │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ ├── Main.java │ │ │ ├── TestingTeam.java │ │ │ └── UserNotFoundException.java │ └── vtEvent.jfc ├── P224_MonitoringVirtualThreadsJmx1 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P224_MonitoringVirtualThreadsJmx2 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P224_MonitoringVirtualThreadsJmx3 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java └── P224_MonitoringVirtualThreadsJmx4 │ ├── README.md │ ├── dumpThreads.json │ ├── pom.xml │ └── src │ └── main │ └── java │ └── modern │ └── challenge │ ├── Main.java │ └── UserNotFoundException.java ├── Chapter11 ├── HTTP Web Server.jmx ├── P225_SimpleVirtualThreadContinuations │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P227_ExtendStructuredTaskScope │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── PublicTransport.java │ │ ├── PublicTransportException.java │ │ ├── PublicTransportOffer.java │ │ ├── PublicTransportScope.java │ │ ├── Ridesharing.java │ │ ├── RidesharingException.java │ │ └── RidesharingOffer.java ├── P228_AssembleStructuredTaskScope │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── PublicTransport.java │ │ ├── PublicTransportException.java │ │ ├── PublicTransportOffer.java │ │ ├── PublicTransportScope.java │ │ ├── Ridesharing.java │ │ ├── RidesharingException.java │ │ ├── RidesharingOffer.java │ │ ├── Travel.java │ │ ├── TravelOffer.java │ │ └── TravelScope.java ├── P229_AssembleStructuredTaskScopeTimeout │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── PublicTransport.java │ │ ├── PublicTransportException.java │ │ ├── PublicTransportOffer.java │ │ ├── PublicTransportScope.java │ │ ├── Ridesharing.java │ │ ├── RidesharingException.java │ │ ├── RidesharingOffer.java │ │ ├── Travel.java │ │ ├── TravelOffer.java │ │ └── TravelScope.java ├── P230_VirtualThreadAndThreadLocal │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P231_IntroScopedValues1 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P231_IntroScopedValues2 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P231_IntroScopedValues3 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P231_IntroScopedValues4 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P232_ScopedValueAndExecutorService │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P233_ChainRebindScopedValues │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P234_ScopedValueAndStructuredTaskScope │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── PublicTransport.java │ │ ├── PublicTransportException.java │ │ ├── PublicTransportOffer.java │ │ ├── PublicTransportScope.java │ │ ├── Ridesharing.java │ │ ├── RidesharingException.java │ │ ├── RidesharingOffer.java │ │ ├── Travel.java │ │ ├── TravelOffer.java │ │ └── TravelScope.java ├── P235_SemaphoreVsExecutor │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P236_AvoidPinningViaLocking │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P237_VirtualThreadProducerConsumer │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── AssemblyLine.java │ │ └── Main.java ├── P238_FixedVirtualThreadProducerConsumer │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── AssemblyLine.java │ │ └── Main.java ├── P239_IncVirtualThreadProducerConsumer │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── AssemblyLine.java │ │ └── Main.java ├── P240_VirtualThreadsHttpServer │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ └── WebServerHandler.java ├── P241_CompletableFutureAndVirtualThreads │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ ├── Main.java │ │ ├── TestingTeam.java │ │ └── UserNotFoundException.java ├── P242_VirtualThreadsWaitNotify1 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P242_VirtualThreadsWaitNotify2 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java └── P242_VirtualThreadsWaitNotify3 │ ├── README.md │ ├── pom.xml │ └── src │ └── main │ └── java │ └── modern │ └── challenge │ ├── Main.java │ └── SignaledObject.java ├── Chapter12 ├── P255_LoggingGC │ ├── README.md │ ├── gclog.txt │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java └── README.md ├── Chapter13 ├── P261_BlockingEchoClient │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P261_BlockingEchoServer │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P262_NonBlockingEchoClient │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P262_NonBlockingEchoServer │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P263_BlockingEchoServer │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P263_ConnectedClient │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P263_ConnectionlessClient │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P265_NetworkInterface │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P266_MulticastClient │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P266_MulticastServer │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P267_BlockingEchoClientKEM │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P267_BlockingEchoServerKEM │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P270_SWSCommandLineTool │ ├── README.md │ ├── README.txt │ └── docs │ │ ├── Java Coding Problems 1st Edition.png │ │ ├── Java Coding Problems 2nd Edition.png │ │ ├── The Complete Coding Interview Guide in Java.png │ │ ├── books.txt │ │ └── jOOQ Masterclass.png ├── P271_ProgrammaticSWS │ ├── README.md │ ├── docs │ │ ├── Java Coding Problems 1st Edition.png │ │ ├── Java Coding Problems 2nd Edition.png │ │ ├── The Complete Coding Interview Guide in Java.png │ │ ├── books.txt │ │ └── jOOQ Masterclass.png │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P271_ProgrammaticSWSExecutor │ ├── README.md │ ├── docs │ │ ├── Java Coding Problems 1st Edition.png │ │ ├── Java Coding Problems 2nd Edition.png │ │ ├── The Complete Coding Interview Guide in Java.png │ │ ├── books.txt │ │ └── jOOQ Masterclass.png │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P271_ProgrammaticSWSFileHandler │ ├── README.md │ ├── docs │ │ ├── Java Coding Problems 1st Edition.png │ │ ├── Java Coding Problems 2nd Edition.png │ │ ├── The Complete Coding Interview Guide in Java.png │ │ ├── books.txt │ │ └── jOOQ Masterclass.png │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P271_ProgrammaticSWSFilters │ ├── README.md │ ├── docs │ │ ├── Java Coding Problems 1st Edition.png │ │ ├── Java Coding Problems 2nd Edition.png │ │ ├── The Complete Coding Interview Guide in Java.png │ │ ├── books.txt │ │ └── jOOQ Masterclass.png │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ └── swslog.txt ├── P272_ProgrammaticSWSAdaptRequest │ ├── README.md │ ├── docs │ │ ├── Java Coding Problems 1st Edition.png │ │ ├── Java Coding Problems 2nd Edition.png │ │ ├── The Complete Coding Interview Guide in Java.png │ │ ├── books.txt │ │ └── jOOQ Masterclass.png │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P273_ProgrammaticSWSComplementHandler │ ├── README.md │ ├── docs │ │ ├── Java Coding Problems 1st Edition.png │ │ ├── Java Coding Problems 2nd Edition.png │ │ ├── The Complete Coding Interview Guide in Java.png │ │ ├── books.txt │ │ └── jOOQ Masterclass.png │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P274_SWSInMemoryFileSystem │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── modern │ │ └── challenge │ │ └── Main.java ├── P275_SWSZipFileSystem │ ├── README.md │ ├── docs │ │ └── books.txt │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── modern │ │ │ └── challenge │ │ │ └── Main.java │ └── zips │ │ ├── README.txt │ │ └── docs.zip └── P276_SWSJavaRuntimeDirectory │ ├── README.md │ ├── pom.xml │ └── src │ └── main │ └── java │ └── modern │ └── challenge │ └── Main.java ├── Java Coding Problems Second Edition.png ├── LICENSE └── README.md /Chapter01/P01_TextBlockSQLJSONHTML/README.md: -------------------------------------------------------------------------------- 1 | # Creating a multiline SQL, JSON, and HTML string 2 | Write a program that declares a multiline string (for instance, SQL, JSON, and HTML strings). -------------------------------------------------------------------------------- /Chapter01/P02_TextBlockDelimiters/README.md: -------------------------------------------------------------------------------- 1 | # Exemplifying the usage of text block delimiters 2 | Write a program that exemplifies step-by-step how the delimiters of a text block affect the resulting string. -------------------------------------------------------------------------------- /Chapter01/P03_TextBlockIndentation/README.md: -------------------------------------------------------------------------------- 1 | # Working with indentation in text blocks 2 | Write a program that exemplifies different techniques to indent a text block. Explain the meaning of incidental and essential white spaces. -------------------------------------------------------------------------------- /Chapter01/P04_TextBlockRemovingIncidentalWhiteSpace/README.md: -------------------------------------------------------------------------------- 1 | # Removing incidental white spaces in text blocks 2 | Highlight the main steps of the algorithm used by the compiler to remove the incidental white spaces of a text block. -------------------------------------------------------------------------------- /Chapter01/P05_TextBlockJustForReadability/README.md: -------------------------------------------------------------------------------- 1 | # Using text blocks just for readability 2 | Write a program that creates a string looking like a text block (multiline string) but acts as a single-line string literal. -------------------------------------------------------------------------------- /Chapter01/P06_TextBlockEscaping/README.md: -------------------------------------------------------------------------------- 1 | # Escaping quotes and line terminators in text blocks 2 | Write a program that exemplifies how to handle Java escape sequences (including quotes, \", and line terminators, \n, \r) in a text block. -------------------------------------------------------------------------------- /Chapter01/P11_RegexNamedGroups/README.md: -------------------------------------------------------------------------------- 1 | # Mixing regular expression with text blocks: 2 | Write an example of mixing regular expressions having named groups with text blocks. -------------------------------------------------------------------------------- /Chapter01/P13_StringConcatJDK11/README.md: -------------------------------------------------------------------------------- 1 | # Concatenating strings vs. StringBuilder 2 | Write a JMH benchmark for comparing string concatenation (via the "+" operator) with StringBuilder approach. -------------------------------------------------------------------------------- /Chapter01/P13_StringConcatJDK11Benchmark/README.md: -------------------------------------------------------------------------------- 1 | # Concatenating strings vs. StringBuilder (Benchmark) 2 | Write a JMH benchmark for comparing string concatenation (via the "+" operator) with StringBuilder approach. -------------------------------------------------------------------------------- /Chapter01/P13_StringConcatJDK8/README.md: -------------------------------------------------------------------------------- 1 | # Concatenating strings vs. StringBuilder 2 | Write a JMH benchmark for comparing string concatenation (via the "+" operator) with StringBuilder approach. -------------------------------------------------------------------------------- /Chapter01/P13_StringConcatJDK8Benchmark/README.md: -------------------------------------------------------------------------------- 1 | # Concatenating strings vs. StringBuilder (Benchmark) 2 | Write a JMH benchmark for comparing string concatenation (via the "+" operator) with StringBuilder approach. -------------------------------------------------------------------------------- /Chapter01/P14_IntegerToStringBenchmark/README.md: -------------------------------------------------------------------------------- 1 | # Converting int to String (Benchmark) 2 | Write a program that provides several common techniques for converting an int to a String. Also, for the proposed solutions, provide a JMH benchmark. -------------------------------------------------------------------------------- /Chapter01/P15_BuiltinStringTemplate/README.md: -------------------------------------------------------------------------------- 1 | # Introducing string templates: 2 | Explain and exemplify the usage of JDK 21 string templates feature. -------------------------------------------------------------------------------- /Chapter01/P16_CustomTemplateProcessor1/README.md: -------------------------------------------------------------------------------- 1 | # Writing a custom template processor: 2 | Introduce the API for writing a user-defined template processor. Next, provide a few examples of custom template processors. -------------------------------------------------------------------------------- /Chapter01/P16_CustomTemplateProcessor2/README.md: -------------------------------------------------------------------------------- 1 | # Writing a custom template processor: 2 | Introduce the API for writing a user-defined template processor. Next, provide a few examples of custom template processors. -------------------------------------------------------------------------------- /Chapter01/P16_CustomTemplateProcessor3/README.md: -------------------------------------------------------------------------------- 1 | # Writing a custom template processor: 2 | Introduce the API for writing a user-defined template processor. Next, provide a few examples of custom template processors. -------------------------------------------------------------------------------- /Chapter01/P16_CustomTemplateProcessor4/README.md: -------------------------------------------------------------------------------- 1 | # Writing a custom template processor: 2 | Introduce the API for writing a user-defined template processor. Next, provide a few examples of custom template processors. -------------------------------------------------------------------------------- /Chapter01/P16_CustomTemplateProcessor5/README.md: -------------------------------------------------------------------------------- 1 | # Writing a custom template processor: 2 | Introduce the API for writing a user-defined template processor. Next, provide a few examples of custom template processors. -------------------------------------------------------------------------------- /Chapter01/P17_LocaleOf/README.md: -------------------------------------------------------------------------------- 1 | # Creating a Locale 2 | Write a program that reveals different approaches for creating a Locale. Also, create language ranges and language priority lists. -------------------------------------------------------------------------------- /Chapter01/P18_LocaleCurrency/README.md: -------------------------------------------------------------------------------- 1 | # Customizing localized date-time formats 2 | Write a program that exemplifies the usage of custom localized date-time formats. -------------------------------------------------------------------------------- /Chapter01/P18_LocaleOfLocalizedDate/README.md: -------------------------------------------------------------------------------- 1 | # Customizing localized date-time formats 2 | Write a program that exemplifies the usage of custom localized date-time formats. -------------------------------------------------------------------------------- /Chapter01/P19_UsingStrictfpClass/README.md: -------------------------------------------------------------------------------- 1 | # Restoring Always-Strict Floating-Point semantics 2 | Explain what the strictfp modifier is and how/where to use it in a Java application. -------------------------------------------------------------------------------- /Chapter01/P19_UsingStrictfpInterface/README.md: -------------------------------------------------------------------------------- 1 | # Restoring Always-Strict Floating-Point semantics 2 | Explain what the strictfp modifier is and how/where to use it in a Java application. -------------------------------------------------------------------------------- /Chapter01/P19_UsingStrictfpInterfaceReflection/README.md: -------------------------------------------------------------------------------- 1 | # Restoring Always-Strict Floating-Point semantics 2 | Explain what the strictfp modifier is and how/where to use it in a Java application. -------------------------------------------------------------------------------- /Chapter01/P23_GetDoubleParts/README.md: -------------------------------------------------------------------------------- 1 | # Getting integral and fractional parts from a double 2 | Write a program that exposes several techniques for getting the integral and fractional parts of a double. -------------------------------------------------------------------------------- /Chapter01/P24_DoubleIsInteger/README.md: -------------------------------------------------------------------------------- 1 | # Testing if a double number is an integer 2 | Write a program that shows several approaches for testing if a double number is an integer. In addition, provide a JMH benchmark for the proposed solutions. -------------------------------------------------------------------------------- /Chapter01/P24_DoubleIsIntegerBenchmark/README.md: -------------------------------------------------------------------------------- 1 | # Testing if a double number is an integer (benchmark) 2 | Write a program that shows several approaches for testing if a double number is an integer. In addition, provide a JMH benchmark for the proposed solutions. -------------------------------------------------------------------------------- /Chapter01/P25_MultiplyHigh/README.md: -------------------------------------------------------------------------------- 1 | # Hooking Java (un)signed integers in a nutshell 2 | Explain and exemplify in code the usage of signed/unsigned integers in Java. -------------------------------------------------------------------------------- /Chapter01/P26_FloorCeilModulus/README.md: -------------------------------------------------------------------------------- 1 | # Returning the flooring/ceiling modulus 2 | Define the floor/ceil modulus based on the floor and ceil operations, and exemplify the result in code lines. -------------------------------------------------------------------------------- /Chapter01/P27_CountPrimeNumbers/README.md: -------------------------------------------------------------------------------- 1 | # Collecting all prime factors of a given number 2 | A prime number is a number divisible by itself and 1 (for instance, 2, 3, and 5 are prime numbers). Write a program that collects all prime factors of a given positive number. -------------------------------------------------------------------------------- /Chapter01/P27_PrimeFactors/README.md: -------------------------------------------------------------------------------- 1 | # Collecting all prime factors of a given number 2 | A prime number is a number divisible by itself and 1 (for instance, 2, 3, and 5 are prime numbers). Write a program that collects all prime factors of a given positive number. -------------------------------------------------------------------------------- /Chapter01/P29_RoundFloatNumber/README.md: -------------------------------------------------------------------------------- 1 | # Rounding a float number to specified decimals 2 | Write a program that contains several approaches for rounding a given float number to specified decimals. -------------------------------------------------------------------------------- /Chapter01/P30_ClampingBetweenMinMax/README.md: -------------------------------------------------------------------------------- 1 | # Clamping a value between min and max: 2 | Provide a solution for clamping a given value between a given minimum and maximum. -------------------------------------------------------------------------------- /Chapter01/P32_UsingTau/README.md: -------------------------------------------------------------------------------- 1 | # Using TAU 2 | Explain the meaning of TAU in geometry/trigonometry and write a program that solves the following problem: A circle has a circumference of 21.33 cm. What is the radius of the circle? -------------------------------------------------------------------------------- /Chapter01/P34_FillArrayRandomData/README.md: -------------------------------------------------------------------------------- 1 | # Filling a long array with pseudo-random numbers 2 | Write a program that fills an array of longs with pseudo-random numbers in a parallel and non-parallel fashion. -------------------------------------------------------------------------------- /Chapter01/P35_InfiniteStreamOfRndGenerators/README.md: -------------------------------------------------------------------------------- 1 | # Creating a stream of pseudo-random generators 2 | Write a program that creates a stream of pseudo-random numbers and a stream of pseudo-random generators. -------------------------------------------------------------------------------- /Chapter02/P38_AsciiVsUnicode/README.md: -------------------------------------------------------------------------------- 1 | # Explain and exemplify UTF-8, UTF-16, and UTF-32: 2 | Provide a detailed explanation of what are UTF-8, UTF-16, and UTF-32. Also, include several snippets of code to show how these work in Java. -------------------------------------------------------------------------------- /Chapter02/P38_Emoji/README.md: -------------------------------------------------------------------------------- 1 | # Explain and exemplify UTF-8, UTF-16, and UTF-32: 2 | Provide a detailed explanation of what are UTF-8, UTF-16, and UTF-32. Also, include several snippets of code to show how these work in Java. -------------------------------------------------------------------------------- /Chapter02/P38_ReadingWritingFileUTF8/README.md: -------------------------------------------------------------------------------- 1 | # Explain and exemplify UTF-8, UTF-16, and UTF-32: 2 | Provide a detailed explanation of what are UTF-8, UTF-16, and UTF-32. Also, include several snippets of code to show how these work in Java. -------------------------------------------------------------------------------- /Chapter02/P38_ReadingWritingFileUTF8/chineseUTF16.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter02/P38_ReadingWritingFileUTF8/chineseUTF16.txt -------------------------------------------------------------------------------- /Chapter02/P38_StringToBinaryEncodings/README.md: -------------------------------------------------------------------------------- 1 | # Explain and exemplify UTF-8, UTF-16, and UTF-32: 2 | Provide a detailed explanation of what are UTF-8, UTF-16, and UTF-32. Also, include several snippets of code to show how these work in Java. -------------------------------------------------------------------------------- /Chapter02/P40_StringIndentity/README.md: -------------------------------------------------------------------------------- 1 | # Returning an identity string: 2 | Write a program that returns a string representation of an object without calling the overridden toString() or hashCode(). -------------------------------------------------------------------------------- /Chapter02/P41_UnamedClassesMain/README.md: -------------------------------------------------------------------------------- 1 | # Hooking unnamed classes and instance main methods: 2 | Give a quick introduction to JDK 21 unnamed classes and instance main methods. -------------------------------------------------------------------------------- /Chapter02/P41_UnamedClassesMain/src/main/java/HelloWorld.java: -------------------------------------------------------------------------------- 1 | void main() { 2 | System.out.println("Hello World!"); 3 | } -------------------------------------------------------------------------------- /Chapter02/P42_SnippetsInJavadoc/README.md: -------------------------------------------------------------------------------- 1 | # Adding code snippets in Java API documentation: 2 | Provide examples of adding code snippets in Java API documentation via the new @snippet tag. -------------------------------------------------------------------------------- /Chapter02/P42_SnippetsInJavadoc/src/snippet-src/DistanceSnippet.java: -------------------------------------------------------------------------------- 1 | Point sp = new Point(12, 56); 2 | Point ep = new Point(43, 45); 3 | 4 | int d = telementer.distance(sp, ep, true); -------------------------------------------------------------------------------- /Chapter02/P42_SnippetsInJavadoc/src/snippet-src/ParamDefaultSnippet.properties: -------------------------------------------------------------------------------- 1 | # @start region=dist 2 | sc=[0,0] 3 | ec=[0,0] 4 | interpolation=false 5 | # @end region=dist 6 | # @start region=at 7 | eps=0.1 8 | type=null 9 | # @end region=at -------------------------------------------------------------------------------- /Chapter02/P42_SnippetsInJavadocPreJDK18/README.md: -------------------------------------------------------------------------------- 1 | # Adding code snippets in Java API documentation: 2 | Provide examples of adding code snippets in Java API documentation via the new @snippet tag. -------------------------------------------------------------------------------- /Chapter02/P43_InvokeDefaultMethodsJDK16/README.md: -------------------------------------------------------------------------------- 1 | # Invoking default methods from Proxy instances: 2 | Write several programs that invoke interface default methods from Proxy instances in JDK 8, JDK 9, and JDK 16. -------------------------------------------------------------------------------- /Chapter02/P43_InvokeDefaultMethodsJDK16/src/main/java/modern/challenge/Book.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public interface Book extends Printable { 4 | } 5 | -------------------------------------------------------------------------------- /Chapter02/P43_InvokeDefaultMethodsJDK8/README.md: -------------------------------------------------------------------------------- 1 | # Invoking default methods from Proxy instances: 2 | Write several programs that invoke interface default methods from Proxy instances in JDK 8, JDK 9, and JDK 16. -------------------------------------------------------------------------------- /Chapter02/P43_InvokeDefaultMethodsJDK8/src/main/java/modern/challenge/Book.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public interface Book extends Printable { 4 | } 5 | -------------------------------------------------------------------------------- /Chapter02/P43_InvokeDefaultMethodsJDK9/README.md: -------------------------------------------------------------------------------- 1 | # Invoking default methods from Proxy instances: 2 | Write several programs that invoke interface default methods from Proxy instances in JDK 8, JDK 9, and JDK 16. -------------------------------------------------------------------------------- /Chapter02/P43_InvokeDefaultMethodsJDK9/src/main/java/modern/challenge/Book.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public interface Book extends Printable { 4 | } 5 | -------------------------------------------------------------------------------- /Chapter02/P44_ByteToHexString/README.md: -------------------------------------------------------------------------------- 1 | # Converting between bytes and hex-encoded strings: 2 | Provide several snippets of code for converting between bytes and hex-encoded strings (including byte arrays). -------------------------------------------------------------------------------- /Chapter02/P46_AnonymousClassesAndStatics/README.md: -------------------------------------------------------------------------------- 1 | # Adding nested classes in anonymous classes: 2 | Write a meaningful example that uses nested classes in anonymous classes (pre-JDK 16, and JDK 16+). -------------------------------------------------------------------------------- /Chapter02/P46_AnonymousClassesAndStatics/src/main/java/modern/challenge/Printer.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public interface Printer { 4 | 5 | public void print(String quality); 6 | } 7 | -------------------------------------------------------------------------------- /Chapter02/P47_ErasureBridge/README.md: -------------------------------------------------------------------------------- 1 | # Exemplify erasure vs. overloading: 2 | Explain in a nutshell what is type erasure in Java, what is polymorphic overloading, and exemplify how they work together. -------------------------------------------------------------------------------- /Chapter02/P47_ErasureGeneric/README.md: -------------------------------------------------------------------------------- 1 | # Exemplify erasure vs. overloading: 2 | Explain in a nutshell what is type erasure in Java, what is polymorphic overloading, and exemplify how they work together. -------------------------------------------------------------------------------- /Chapter02/P47_ErasureHeapPollution/README.md: -------------------------------------------------------------------------------- 1 | # Exemplify erasure vs. overloading: 2 | Explain in a nutshell what is type erasure in Java, what is polymorphic overloading, and exemplify how they work together. -------------------------------------------------------------------------------- /Chapter02/P47_ErasureVsOverloading/README.md: -------------------------------------------------------------------------------- 1 | # Exemplify erasure vs. overloading: 2 | Explain in a nutshell what is type erasure in Java, what is polymorphic overloading, and exemplify how they work together. -------------------------------------------------------------------------------- /Chapter02/P47_ErasureVsOverloading/src/main/java/modern/challenge/A.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public class A {} 4 | -------------------------------------------------------------------------------- /Chapter02/P47_ErasureVsOverloading/src/main/java/modern/challenge/B.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public class B {} 4 | -------------------------------------------------------------------------------- /Chapter02/P47_PolymorphicOverloading/README.md: -------------------------------------------------------------------------------- 1 | # Exemplify erasure vs. overloading: 2 | Explain in a nutshell what is type erasure in Java, what is polymorphic overloading, and exemplify how they work together. -------------------------------------------------------------------------------- /Chapter02/P48_XlintDefaultConstructor/README.md: -------------------------------------------------------------------------------- 1 | # Xlinting default constructors: 2 | Explain and exemplify the JDK 16+ hint for classes with default constructors, -Xlint:missing-explicit-ctor. -------------------------------------------------------------------------------- /Chapter02/P48_XlintDefaultConstructor/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module P48_XlintDefaultConstructor { 2 | exports modern.challenge; 3 | } 4 | -------------------------------------------------------------------------------- /Chapter02/P49_ReceiverParameter/README.md: -------------------------------------------------------------------------------- 1 | # Working with the receiver parameter: 2 | Explain the role of the Java receiver parameter and exemplify its usage in code. -------------------------------------------------------------------------------- /Chapter02/P49_ReceiverParameter/src/main/java/modern/challenge/Cashed.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Target; 5 | 6 | @Target(ElementType.TYPE_USE) 7 | public @interface Cashed {} 8 | -------------------------------------------------------------------------------- /Chapter02/P49_ReceiverParameter/src/main/java/modern/challenge/New.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Target; 5 | 6 | @Target(ElementType.TYPE_USE) 7 | public @interface New {} 8 | -------------------------------------------------------------------------------- /Chapter02/P49_ReceiverParameter/src/main/java/modern/challenge/Ordered.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Target; 5 | 6 | @Target(ElementType.TYPE_USE) 7 | public @interface Ordered {} 8 | -------------------------------------------------------------------------------- /Chapter02/P49_ReceiverParameter/src/main/java/modern/challenge/Shipped.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Target; 5 | 6 | @Target(ElementType.TYPE_USE) 7 | public @interface Shipped {} 8 | -------------------------------------------------------------------------------- /Chapter02/P50_ImmutableStack/README.md: -------------------------------------------------------------------------------- 1 | # Implementing an immutable stack: 2 | Provide a program that creates from zero an immutable stack implementation (implement isEmpty(), push(), pop(), and peek() operations). -------------------------------------------------------------------------------- /Chapter02/P51_CommonStringMistake/README.md: -------------------------------------------------------------------------------- 1 | # Revealing a common mistake with Strings: 2 | Write a simple use case of Strings that contain a common mistake (for instance, related to String immutability characteristic). -------------------------------------------------------------------------------- /Chapter02/P52_Common5NPE/README.md: -------------------------------------------------------------------------------- 1 | # Using the enhanced NullPointerException: 2 | Exemplify from your experience the top 5 causes of NullPointerException and explain how JDK 14 improves NPE messages. -------------------------------------------------------------------------------- /Chapter02/P52_WorkingAroundNPE/README.md: -------------------------------------------------------------------------------- 1 | # Using the enhanced NullPointerException: 2 | Exemplify from your experience the top 5 causes of NullPointerException and explain how JDK 14 improves NPE messages. -------------------------------------------------------------------------------- /Chapter02/P53_YieldStatementBlocks/README.md: -------------------------------------------------------------------------------- 1 | # Using yield in switch expressions: 2 | Explain and exemplify the usage of the yield keyword with switch expressions in JDK 13+. -------------------------------------------------------------------------------- /Chapter02/P53_YieldStatementBlocks/src/main/java/modern/challenge/FootballPlayer.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public class FootballPlayer extends Player { 4 | } 5 | -------------------------------------------------------------------------------- /Chapter02/P53_YieldStatementBlocks/src/main/java/modern/challenge/Player.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public class Player { 4 | } 5 | -------------------------------------------------------------------------------- /Chapter02/P53_YieldStatementBlocks/src/main/java/modern/challenge/SnookerPlayer.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public class SnookerPlayer extends Player { 4 | } 5 | -------------------------------------------------------------------------------- /Chapter02/P53_YieldStatementBlocks/src/main/java/modern/challenge/TennisPlayer.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public class TennisPlayer extends Player{ 4 | } 5 | -------------------------------------------------------------------------------- /Chapter02/P53_YieldSwitchExpression/README.md: -------------------------------------------------------------------------------- 1 | # Using yield in switch expressions: 2 | Explain and exemplify the usage of the yield keyword with switch expressions in JDK 13+. -------------------------------------------------------------------------------- /Chapter02/P53_YieldSwitchExpression/src/main/java/modern/challenge/FootballPlayer.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public class FootballPlayer extends Player { 4 | } 5 | -------------------------------------------------------------------------------- /Chapter02/P53_YieldSwitchExpression/src/main/java/modern/challenge/Player.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public class Player { 4 | } 5 | -------------------------------------------------------------------------------- /Chapter02/P53_YieldSwitchExpression/src/main/java/modern/challenge/SnookerPlayer.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public class SnookerPlayer extends Player { 4 | } 5 | -------------------------------------------------------------------------------- /Chapter02/P53_YieldSwitchExpression/src/main/java/modern/challenge/TennisPlayer.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public class TennisPlayer extends Player{ 4 | } 5 | -------------------------------------------------------------------------------- /Chapter02/P54_CaseNullClauseInSwitch/README.md: -------------------------------------------------------------------------------- 1 | # Tackling the case null clause in switch: 2 | Write a bunch of examples to show different approaches for handling null values in switch expressions (including JDK 17+ approaches). -------------------------------------------------------------------------------- /Chapter02/P54_CaseNullClauseInSwitch/src/main/java/modern/challenge/FootballPlayer.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public class FootballPlayer extends Player { 4 | } 5 | -------------------------------------------------------------------------------- /Chapter02/P54_CaseNullClauseInSwitch/src/main/java/modern/challenge/Player.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public class Player { 4 | } 5 | -------------------------------------------------------------------------------- /Chapter02/P54_CaseNullClauseInSwitch/src/main/java/modern/challenge/SnookerPlayer.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public class SnookerPlayer extends Player { 4 | } 5 | -------------------------------------------------------------------------------- /Chapter02/P54_CaseNullClauseInSwitch/src/main/java/modern/challenge/TennisPlayer.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public class TennisPlayer extends Player{ 4 | } 5 | -------------------------------------------------------------------------------- /Chapter02/P55_EqualOperatorVsEquals/README.md: -------------------------------------------------------------------------------- 1 | # Taking on the hard way to discover equals(): 2 | Explain and exemplify how is equals() different from the == operator. -------------------------------------------------------------------------------- /Chapter02/P56_ClassicInstanceof/README.md: -------------------------------------------------------------------------------- 1 | # Hooking instanceof in a nutshell: 2 | Provide a brief overview with snippets of code for highlighting the main aspect of the instanceof operator. -------------------------------------------------------------------------------- /Chapter02/P58_TypePatternMatchingInstanceof/README.md: -------------------------------------------------------------------------------- 1 | # Introducing type patterns matching for instanceof: 2 | Provide the theoretical and practical support for using the type patterns matching for instanceof. -------------------------------------------------------------------------------- /Chapter02/P59_BindingVariableScopeInstanceof/README.md: -------------------------------------------------------------------------------- 1 | # Handling the scope of a binding variable in type patterns for instanceof: 2 | Explain in detail, including snippets of code, the scope of binding variables in type patterns for instanceof. -------------------------------------------------------------------------------- /Chapter02/P60_RewritingEqualsTypePatternInstanceof/README.md: -------------------------------------------------------------------------------- 1 | # Rewriting equals() via type patterns for instanceof: 2 | Exemplify in code the implementation of equals() (including for generic classes) before and after type patterns for instanceof have been introduced. -------------------------------------------------------------------------------- /Chapter02/P61_TypePatternInstanceofGenerics/README.md: -------------------------------------------------------------------------------- 1 | # Tackling type patterns for instanceof and generics: 2 | Provide several examples that use the combo type patterns for instanceof and generics. -------------------------------------------------------------------------------- /Chapter02/P62_TypePatternInstanceofStream/README.md: -------------------------------------------------------------------------------- 1 | # Tackling type patterns for instanceof and streams: 2 | Can we use type patterns for instanceof and the Stream API together? If yes, provide at least an example. -------------------------------------------------------------------------------- /Chapter02/P63_TypePatternMatchingSwitch/README.md: -------------------------------------------------------------------------------- 1 | # Introducing type patterns matching for switch: 2 | Type patterns are available for instanceof but are also available for switch. Provide here the theoretical headlines and an example of this topic. -------------------------------------------------------------------------------- /Chapter02/P64_GuardedPatternsSwitch1/README.md: -------------------------------------------------------------------------------- 1 | # Adding guarded pattern labels in switch: 2 | Provide a brief coverage of guarded pattern labels in switch for JDK 17 and 21. -------------------------------------------------------------------------------- /Chapter02/P64_GuardedPatternsSwitch1JDK17/README.md: -------------------------------------------------------------------------------- 1 | # Adding guarded pattern labels in switch: 2 | Provide a brief coverage of guarded pattern labels in switch for JDK 17 and 21. -------------------------------------------------------------------------------- /Chapter02/P64_GuardedPatternsSwitch2/README.md: -------------------------------------------------------------------------------- 1 | # Adding guarded pattern labels in switch: 2 | Provide a brief coverage of guarded pattern labels in switch for JDK 17 and 21. -------------------------------------------------------------------------------- /Chapter02/P64_GuardedPatternsSwitch2JDK17/README.md: -------------------------------------------------------------------------------- 1 | # Adding guarded pattern labels in switch: 2 | Provide a brief coverage of guarded pattern labels in switch for JDK 17 and 21. -------------------------------------------------------------------------------- /Chapter02/P65_TypePatternSwitchDominance/README.md: -------------------------------------------------------------------------------- 1 | # Dealing with pattern labels dominance in switch: 2 | Pattern labels dominance in switch is a cool feature, so exemplify it here in a comprehensive approach with plenty of examples. -------------------------------------------------------------------------------- /Chapter02/P66_CompletenessInSwitchJDK20/README.md: -------------------------------------------------------------------------------- 1 | # Dealing with completeness (type coverage) in pattern labels for switch: 2 | This is another cool topic for switch expression. Explain and exemplify it in detail (theory ad examples). -------------------------------------------------------------------------------- /Chapter02/P66_CompletenessInSwitchJDK21/README.md: -------------------------------------------------------------------------------- 1 | # Dealing with completeness (type coverage) in pattern labels for switch: 2 | This is another cool topic for switch expression. Explain and exemplify it in detail (theory ad examples). -------------------------------------------------------------------------------- /Chapter02/P67_UnconditionalPatterns/README.md: -------------------------------------------------------------------------------- 1 | # Understanding the unconditional patterns and nulls in switch expressions: 2 | Explain how null values are handled by unconditional patterns of switch expressions before and after JDK 19. -------------------------------------------------------------------------------- /Chapter02/P67_UnconditionalPatternsJDK17/README.md: -------------------------------------------------------------------------------- 1 | # Understanding the unconditional patterns and nulls in switch expressions: 2 | Explain how null values are handled by unconditional patterns of switch expressions before and after JDK 19. -------------------------------------------------------------------------------- /Chapter03/P69_DateToYearMonth/README.md: -------------------------------------------------------------------------------- 1 | # Converting between Date and YearMonth: 2 | Write an application that converts between java.util.Date and java.time.YearMonth and vice-versa. -------------------------------------------------------------------------------- /Chapter03/P70_IntToYearMonth/README.md: -------------------------------------------------------------------------------- 1 | # Converting between int and YearMonth: 2 | Let’s consider that a YearMonth is given (for instance, 2023-02). Convert it to an integer representation (for instance, 24277) that can be converted back to YearMonth. -------------------------------------------------------------------------------- /Chapter03/P72_LeapYear/README.md: -------------------------------------------------------------------------------- 1 | # Checking leap year: 2 | Let’s consider that an integer is given representing a year. Write an application that checks if this year is a leap year. Provide at least three solutions. -------------------------------------------------------------------------------- /Chapter03/P73_QuarterOfDate/README.md: -------------------------------------------------------------------------------- 1 | # Calculating the quarter of a given date: 2 | Let’s consider that a java.util.Date is given. Write a program that returns the quarter containing this date as an integer (1, 2, 3, or 4) and as a string (Q1, Q2, Q3, or Q4). -------------------------------------------------------------------------------- /Chapter03/P75_MonthFromQuarter/README.md: -------------------------------------------------------------------------------- 1 | # Extracting the months from a given quarter: 2 | Let’s consider that a quarter is given (as an integer, or a string (Q1, Q2, Q3, or Q4), or a LocalDate). Write a program that extracts the names of the months of this quarter. -------------------------------------------------------------------------------- /Chapter03/P76_PregnancyDueDateCalculator/README.md: -------------------------------------------------------------------------------- 1 | # Computing pregnancy due date: 2 | Write a pregnancy due date calculator. -------------------------------------------------------------------------------- /Chapter03/P77_Stopwatch/README.md: -------------------------------------------------------------------------------- 1 | # Implementing a stopwatch: 2 | Write a program that implements a stopwatch via System.currentTimeMillis() and via Instant.now(). -------------------------------------------------------------------------------- /Chapter03/P78_FromMidnightToNow/README.md: -------------------------------------------------------------------------------- 1 | # Extracting the count of milliseconds since midnight: 2 | Let’s consider that a LocalDateTime is given. Write an application that counts the milliseconds passed from midnight to this LocalDateTime. -------------------------------------------------------------------------------- /Chapter03/P80_SystemUTCVsSystemDefaultZone/README.md: -------------------------------------------------------------------------------- 1 | # Explaining the difference between Clock.systemUTC() and Clock.systemDefaultZone(): 2 | Explain via meaningful examples what is the difference between systemUTC() and systemDefaultZone(). -------------------------------------------------------------------------------- /Chapter03/P81_WeekDayName/README.md: -------------------------------------------------------------------------------- 1 | # Displaying the names of the days of the week: 2 | Display the names of the days of the week via the java.text.DateFormatSymbols API. -------------------------------------------------------------------------------- /Chapter03/P85_QuartersBetweenTwoDates/README.md: -------------------------------------------------------------------------------- 1 | # Getting the number of quarters between two dates: 2 | Let’s consider that a date-time range via two LocalDate is given. Write a program that counts the number of quarters contained in this range. -------------------------------------------------------------------------------- /Chapter03/P86_ConvertCalendarToLocalDateTime/README.md: -------------------------------------------------------------------------------- 1 | # Converting Calendar to LocalDateTime: 2 | Write a program that converts the given Calendar into a LocalDateTime (default time zone), respectively into a ZonedDateTime (for time zone Asia/Calcutta). -------------------------------------------------------------------------------- /Chapter04/P100_GenericRecords/README.md: -------------------------------------------------------------------------------- 1 | # Using generic records in record patterns: 2 | Write an application that highlights the declaration and usage of generic records. -------------------------------------------------------------------------------- /Chapter04/P100_GenericRecords/src/main/java/modern/challenge/ContainerRecord.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record ContainerRecord(C c) {} 4 | -------------------------------------------------------------------------------- /Chapter04/P100_GenericRecords/src/main/java/modern/challenge/EngineRecord.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record EngineRecord(X x, Y y, Z z) {} 4 | -------------------------------------------------------------------------------- /Chapter04/P100_GenericRecords/src/main/java/modern/challenge/FruitRecord.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record FruitRecord(T t, String country) {} 4 | -------------------------------------------------------------------------------- /Chapter04/P100_GenericRecords/src/main/java/modern/challenge/MelonRecord.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record MelonRecord(String type, float weight) {} 4 | -------------------------------------------------------------------------------- /Chapter04/P101_UnconditionalPatternRecords/README.md: -------------------------------------------------------------------------------- 1 | # Handling nulls in nested record patterns: 2 | Explain and exemplify how to deal with null values in record patterns (explain the edge case of null values in nested record patterns as well). -------------------------------------------------------------------------------- /Chapter04/P101_UnconditionalPatternRecords/src/main/java/modern/challenge/EggplantRecord.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record EggplantRecord(SeedRecord seed, float weight) implements Fruit {} 4 | -------------------------------------------------------------------------------- /Chapter04/P101_UnconditionalPatternRecords/src/main/java/modern/challenge/Fruit.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public interface Fruit {} 4 | -------------------------------------------------------------------------------- /Chapter04/P101_UnconditionalPatternRecords/src/main/java/modern/challenge/MelonRecord.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record MelonRecord(SeedRecord seed, float weight) implements Fruit {} 4 | -------------------------------------------------------------------------------- /Chapter04/P101_UnconditionalPatternRecords/src/main/java/modern/challenge/SeedRecord.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record SeedRecord(String type, String country) implements Fruit {} 4 | -------------------------------------------------------------------------------- /Chapter04/P102_StrShortener/src/main/java/modern/challenge/Concat.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | record Concat(Str first, Str second) implements Str {} -------------------------------------------------------------------------------- /Chapter04/P102_StrShortener/src/main/java/modern/challenge/Literal.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | record Literal(String text) implements Str {} 4 | -------------------------------------------------------------------------------- /Chapter04/P102_StrShortener/src/main/java/modern/challenge/Str.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | interface Str {} 4 | -------------------------------------------------------------------------------- /Chapter04/P102_StrShortener/src/main/java/modern/challenge/Variable.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | record Variable(String name) implements Str {} 4 | -------------------------------------------------------------------------------- /Chapter04/P103_UnamedVariables/README.md: -------------------------------------------------------------------------------- 1 | # Hooking unnamed patterns and variables: 2 | Explain and exemplify the JDK 21 preview feature covering unnamed patterns and variables. -------------------------------------------------------------------------------- /Chapter04/P103_UnnamedPatternSwitch1/README.md: -------------------------------------------------------------------------------- 1 | # Hooking unnamed patterns and variables: 2 | Explain and exemplify the JDK 21 preview feature covering unnamed patterns and variables. -------------------------------------------------------------------------------- /Chapter04/P103_UnnamedPatternSwitch1/src/main/java/modern/challenge/Appointment.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | import java.time.LocalDate; 4 | 5 | public record Appointment(LocalDate date, Doctor doctor) {} 6 | -------------------------------------------------------------------------------- /Chapter04/P103_UnnamedPatternSwitch1/src/main/java/modern/challenge/Doctor.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record Doctor(String name, String specialty) implements Staff {} 4 | -------------------------------------------------------------------------------- /Chapter04/P103_UnnamedPatternSwitch1/src/main/java/modern/challenge/Patient.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record Patient(String name, int npi, Appointment appointment) {} 4 | -------------------------------------------------------------------------------- /Chapter04/P103_UnnamedPatternSwitch1/src/main/java/modern/challenge/Resident.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record Resident(String name, Doctor doctor) implements Staff {} 4 | -------------------------------------------------------------------------------- /Chapter04/P103_UnnamedPatternSwitch1/src/main/java/modern/challenge/Staff.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public interface Staff {} 4 | -------------------------------------------------------------------------------- /Chapter04/P103_UnnamedPatternSwitch2/README.md: -------------------------------------------------------------------------------- 1 | # Hooking unnamed patterns and variables: 2 | Explain and exemplify the JDK 21 preview feature covering unnamed patterns and variables. -------------------------------------------------------------------------------- /Chapter04/P103_UnnamedPatternSwitch2/src/main/java/modern/challenge/Car.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record Car(E engineType) {} 4 | -------------------------------------------------------------------------------- /Chapter04/P103_UnnamedPatternSwitch2/src/main/java/modern/challenge/DSLEngine.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public final class DSLEngine extends EngineType {} -------------------------------------------------------------------------------- /Chapter04/P103_UnnamedPatternSwitch2/src/main/java/modern/challenge/ESSEngine.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public final class ESSEngine extends EngineType {} 4 | -------------------------------------------------------------------------------- /Chapter04/P103_UnnamedPatternSwitch2/src/main/java/modern/challenge/EngineType.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public sealed abstract class EngineType permits ESSEngine, DSLEngine, LPGEngine {} 4 | -------------------------------------------------------------------------------- /Chapter04/P103_UnnamedPatternSwitch2/src/main/java/modern/challenge/LPGEngine.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public final class LPGEngine extends EngineType {} 4 | -------------------------------------------------------------------------------- /Chapter04/P103_UnnamedPatternsInstanceof/README.md: -------------------------------------------------------------------------------- 1 | # Hooking unnamed patterns and variables: 2 | Explain and exemplify the JDK 21 preview feature covering unnamed patterns and variables. -------------------------------------------------------------------------------- /Chapter04/P103_UnnamedPatternsInstanceof/src/main/java/modern/challenge/Appointment.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | import java.time.LocalDate; 4 | 5 | public record Appointment(LocalDate date, Doctor doctor) {} 6 | -------------------------------------------------------------------------------- /Chapter04/P103_UnnamedPatternsInstanceof/src/main/java/modern/challenge/Doctor.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record Doctor(String name, String specialty) implements Staff {} 4 | -------------------------------------------------------------------------------- /Chapter04/P103_UnnamedPatternsInstanceof/src/main/java/modern/challenge/Patient.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record Patient(String name, int npi, Appointment appointment) {} 4 | -------------------------------------------------------------------------------- /Chapter04/P103_UnnamedPatternsInstanceof/src/main/java/modern/challenge/Resident.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record Resident(String name, Doctor doctor) implements Staff {} 4 | -------------------------------------------------------------------------------- /Chapter04/P103_UnnamedPatternsInstanceof/src/main/java/modern/challenge/Staff.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public interface Staff {} 4 | -------------------------------------------------------------------------------- /Chapter04/P104_JavaRecordsDependencyInjection/src/main/java/modern/challenge/record/Author.java: -------------------------------------------------------------------------------- 1 | package modern.challenge.record; 2 | 3 | import java.util.List; 4 | 5 | public record Author(String name, String genre, List books) {} 6 | -------------------------------------------------------------------------------- /Chapter04/P104_JavaRecordsDependencyInjection/src/main/java/modern/challenge/record/Book.java: -------------------------------------------------------------------------------- 1 | package modern.challenge.record; 2 | 3 | public record Book(String title, String isbn) {} 4 | -------------------------------------------------------------------------------- /Chapter04/P104_JavaRecordsInConfigs/README.md: -------------------------------------------------------------------------------- 1 | # Tackling records in Spring Boot: 2 | Write several applications for exemplifying different use cases of records in Spring Boot (for instance, using records in templates, using records for configurations, and so on). -------------------------------------------------------------------------------- /Chapter04/P104_JavaRecordsInConfigs/src/main/java/modern/challenge/record/Author.java: -------------------------------------------------------------------------------- 1 | package modern.challenge.record; 2 | 3 | import java.util.List; 4 | 5 | public record Author(String name, String genre, List books) {} 6 | -------------------------------------------------------------------------------- /Chapter04/P104_JavaRecordsInConfigs/src/main/java/modern/challenge/record/Book.java: -------------------------------------------------------------------------------- 1 | package modern.challenge.record; 2 | 3 | public record Book(String title, String isbn) {} 4 | -------------------------------------------------------------------------------- /Chapter04/P104_JavaRecordsInConfigs/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | bookstore.bestseller.author=Joana Nimar 2 | bookstore.bestseller.book=Prague history -------------------------------------------------------------------------------- /Chapter04/P104_JavaRecordsInControllers/README.md: -------------------------------------------------------------------------------- 1 | # Tackling records in Spring Boot: 2 | Write several applications for exemplifying different use cases of records in Spring Boot (for instance, using records in templates, using records for configurations, and so on). -------------------------------------------------------------------------------- /Chapter04/P104_JavaRecordsInControllers/src/main/java/modern/challenge/record/Author.java: -------------------------------------------------------------------------------- 1 | package modern.challenge.record; 2 | 3 | import java.util.List; 4 | 5 | public record Author(String name, String genre, List books) {} 6 | -------------------------------------------------------------------------------- /Chapter04/P104_JavaRecordsInControllers/src/main/java/modern/challenge/record/Book.java: -------------------------------------------------------------------------------- 1 | package modern.challenge.record; 2 | 3 | public record Book(String title, String isbn) {} 4 | -------------------------------------------------------------------------------- /Chapter04/P104_JavaRecordsInTemplates/README.md: -------------------------------------------------------------------------------- 1 | # Tackling records in Spring Boot: 2 | Write several applications for exemplifying different use cases of records in Spring Boot (for instance, using records in templates, using records for configurations, and so on). -------------------------------------------------------------------------------- /Chapter04/P104_JavaRecordsInTemplates/src/main/java/modern/challenge/record/Author.java: -------------------------------------------------------------------------------- 1 | package modern.challenge.record; 2 | 3 | import java.util.List; 4 | 5 | public record Author(String name, String genre, List books) {} 6 | -------------------------------------------------------------------------------- /Chapter04/P104_JavaRecordsInTemplates/src/main/java/modern/challenge/record/Book.java: -------------------------------------------------------------------------------- 1 | package modern.challenge.record; 2 | 3 | public record Book(String title, String isbn) {} 4 | -------------------------------------------------------------------------------- /Chapter04/P104_JavaRecordsInTemplates/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.thymeleaf.cache=false -------------------------------------------------------------------------------- /Chapter04/P105_DtoRecordConstructor/README.md: -------------------------------------------------------------------------------- 1 | # Tackling records in JPA: 2 | Write several applications for exemplifying different use cases of records in JPA (for instance, using records and constructor expression, using records and result transformers, and so on). -------------------------------------------------------------------------------- /Chapter04/P105_DtoRecordConstructor/src/main/java/com/bookstore/dto/AuthorDto.java: -------------------------------------------------------------------------------- 1 | package com.bookstore.dto; 2 | 3 | public record AuthorDto(String name, int age) {} 4 | -------------------------------------------------------------------------------- /Chapter04/P105_DtoRecordConstructorExpression/src/main/java/com/bookstore/dto/AuthorDto.java: -------------------------------------------------------------------------------- 1 | package com.bookstore.dto; 2 | 3 | public record AuthorDto(String name, int age) {} 4 | -------------------------------------------------------------------------------- /Chapter04/P105_DtoRecordJbcTemplate/README.md: -------------------------------------------------------------------------------- 1 | # Tackling records in JPA: 2 | Write several applications for exemplifying different use cases of records in JPA (for instance, using records and constructor expression, using records and result transformers, and so on). -------------------------------------------------------------------------------- /Chapter04/P105_DtoRecordJbcTemplate/src/main/java/com/bookstore/jdbcTemplate/dto/BookDto.java: -------------------------------------------------------------------------------- 1 | package com.bookstore.jdbcTemplate.dto; 2 | 3 | public record BookDto(Long id, String title) {} -------------------------------------------------------------------------------- /Chapter04/P105_DtoRecordResultTransformer/src/main/java/com/bookstore/dto/BookDto.java: -------------------------------------------------------------------------------- 1 | package com.bookstore.dto; 2 | 3 | public record BookDto(Long id, String title) {} 4 | -------------------------------------------------------------------------------- /Chapter04/P105_RecordAndEmbeddables/README.md: -------------------------------------------------------------------------------- 1 | # Tackling records in JPA: 2 | Write several applications for exemplifying different use cases of records in JPA (for instance, using records and constructor expression, using records and result transformers, and so on). -------------------------------------------------------------------------------- /Chapter04/P105_RecordAndEmbeddables/src/main/java/com/bookstore/dto/AuthorDto.java: -------------------------------------------------------------------------------- 1 | package com.bookstore.dto; 2 | 3 | import com.bookstore.embeddable.Contact; 4 | 5 | public record AuthorDto(String name, int age, Contact contact) {} 6 | -------------------------------------------------------------------------------- /Chapter04/P105_RecordAndEmbeddables/src/main/java/com/bookstore/embeddable/Contact.java: -------------------------------------------------------------------------------- 1 | package com.bookstore.embeddable; 2 | 3 | import jakarta.persistence.Embeddable; 4 | 5 | @Embeddable 6 | public record Contact(String email, String twitter, String phone) {} 7 | -------------------------------------------------------------------------------- /Chapter04/P106_RecordAndjOOQMultiset/README.md: -------------------------------------------------------------------------------- 1 | # Tacking records in jOOQ: 2 | Write several applications for exemplifying different use cases of records in jOOQ (for instance, using records and the MULTISET operator). -------------------------------------------------------------------------------- /Chapter04/P106_RecordAndjOOQMultiset/src/main/java/com/classicmodels/dto/RecordManager.java: -------------------------------------------------------------------------------- 1 | package com.classicmodels.dto; 2 | 3 | import java.util.List; 4 | 5 | public record RecordManager(Long managerId, String managerName, List offices) {} -------------------------------------------------------------------------------- /Chapter04/P106_RecordAndjOOQMultiset/src/main/java/com/classicmodels/dto/RecordOffice.java: -------------------------------------------------------------------------------- 1 | package com.classicmodels.dto; 2 | 3 | public record RecordOffice(String officeCode, String state, String city) {} 4 | -------------------------------------------------------------------------------- /Chapter04/P106_RecordAndjOOQMultiset/src/main/java/com/classicmodels/dto/RecordProduct.java: -------------------------------------------------------------------------------- 1 | package com.classicmodels.dto; 2 | 3 | public record RecordProduct(String productName, String productVendor, Integer quantityInStock) {} 4 | -------------------------------------------------------------------------------- /Chapter04/P106_RecordAndjOOQMultisetAgg/README.md: -------------------------------------------------------------------------------- 1 | # Tacking records in jOOQ: 2 | Write several applications for exemplifying different use cases of records in jOOQ (for instance, using records and the MULTISET operator). -------------------------------------------------------------------------------- /Chapter04/P106_RecordAndjOOQMultisetAgg/src/main/java/com/classicmodels/dto/RecordManager.java: -------------------------------------------------------------------------------- 1 | package com.classicmodels.dto; 2 | 3 | import java.util.List; 4 | 5 | public record RecordManager(Long managerId, String managerName, List offices) {} -------------------------------------------------------------------------------- /Chapter04/P106_RecordAndjOOQMultisetAgg/src/main/java/com/classicmodels/dto/RecordOffice.java: -------------------------------------------------------------------------------- 1 | package com.classicmodels.dto; 2 | 3 | public record RecordOffice(String officeCode, String state, String city) {} 4 | -------------------------------------------------------------------------------- /Chapter04/P106_RecordAndjOOQMultisetAgg/src/main/java/com/classicmodels/dto/RecordProduct.java: -------------------------------------------------------------------------------- 1 | package com.classicmodels.dto; 2 | 3 | public record RecordProduct(String productName, String productVendor, Integer quantityInStock) {} 4 | -------------------------------------------------------------------------------- /Chapter04/P88_SimpleRecord/README.md: -------------------------------------------------------------------------------- 1 | # Declaring a Java record: 2 | Write an application that exemplifies the creation of a Java record. Moreover, provide a short description of the artifacts generated by the compiler for a record behind the scene. -------------------------------------------------------------------------------- /Chapter04/P88_SimpleRecord/src/main/java/modern/challenge/MelonRecord.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record MelonRecord(String type, float weight) {} 4 | -------------------------------------------------------------------------------- /Chapter04/P89_RecordCanonicalCntr/README.md: -------------------------------------------------------------------------------- 1 | # Introducing the canonical and compact constructors for records: 2 | Explain the role of the built-in record’s canonical and compact constructors. Provide examples when it makes sense to provide explicit such constructors. -------------------------------------------------------------------------------- /Chapter04/P90_EnrichedRecord/README.md: -------------------------------------------------------------------------------- 1 | # Adding more artifacts in a record: 2 | Provide a meaningful list of examples about adding explicit artifacts in Java records (for instance, adding instance methods, static artifacts, and so on). -------------------------------------------------------------------------------- /Chapter04/P92_RecordMultipleCntrs/README.md: -------------------------------------------------------------------------------- 1 | # Defining multiple constructors in a record: 2 | Exemplify several approaches for declaring multiple constructors in a record. -------------------------------------------------------------------------------- /Chapter04/P93_RecordAndInterfaces/README.md: -------------------------------------------------------------------------------- 1 | # Implementing interfaces in records: 2 | Write a program that shows how to implement interfaces in records. -------------------------------------------------------------------------------- /Chapter04/P94_RecordSerialization/README.md: -------------------------------------------------------------------------------- 1 | # Understanding records serialization: 2 | Explain in detail and exemplify how records serialization works behind the scene. -------------------------------------------------------------------------------- /Chapter04/P94_RecordSerialization/object.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter04/P94_RecordSerialization/object.data -------------------------------------------------------------------------------- /Chapter04/P94_RecordSerialization/object_malicious.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter04/P94_RecordSerialization/object_malicious.data -------------------------------------------------------------------------------- /Chapter04/P94_RecordSerialization/object_record.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter04/P94_RecordSerialization/object_record.data -------------------------------------------------------------------------------- /Chapter04/P94_RecordSerialization/object_record_malicious.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter04/P94_RecordSerialization/object_record_malicious.data -------------------------------------------------------------------------------- /Chapter04/P94_RefactoringSerialization/README.md: -------------------------------------------------------------------------------- 1 | # Understanding records serialization: 2 | Explain in detail and exemplify how records serialization works behind the scene. -------------------------------------------------------------------------------- /Chapter04/P94_RefactoringSerialization/object.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter04/P94_RefactoringSerialization/object.data -------------------------------------------------------------------------------- /Chapter04/P94_RefactoringSerialization/object_malicious.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter04/P94_RefactoringSerialization/object_malicious.data -------------------------------------------------------------------------------- /Chapter04/P95_RecordCanonicalCntrReflection/README.md: -------------------------------------------------------------------------------- 1 | # Invoking the canonical constructor via reflection: 2 | Write a program that exemplifies how to invoke via reflection the canonical constructor of a record. -------------------------------------------------------------------------------- /Chapter04/P95_RecordCanonicalCntrReflection/src/main/java/modern/challenge/MelonMarketRecord.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | import java.util.List; 4 | 5 | public record MelonMarketRecord(List melons, String country) {} -------------------------------------------------------------------------------- /Chapter04/P95_RecordCanonicalCntrReflection/src/main/java/modern/challenge/MelonRecord.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record MelonRecord(String type, float weight) {} -------------------------------------------------------------------------------- /Chapter04/P96_UsingRecordsInStreams/README.md: -------------------------------------------------------------------------------- 1 | # Using records in streams: 2 | Write several examples to highlight the usage of records for simplifying functional expressions relying on Stream API. -------------------------------------------------------------------------------- /Chapter04/P96_UsingRecordsInStreams/src/main/java/modern/challenge/MelonRecord.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record MelonRecord(String type, float weight) {} -------------------------------------------------------------------------------- /Chapter04/P96_UsingRecordsInStreams/src/main/java/modern/challenge/WeightsAndTotalRecord.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | import java.util.List; 4 | 5 | public record WeightsAndTotalRecord(double totalWeight, List weights) {} 6 | -------------------------------------------------------------------------------- /Chapter04/P97_RecordPatternInstanceof/README.md: -------------------------------------------------------------------------------- 1 | # Introducing record pattern for instanceof: 2 | Write a bunch of examples that introduce record patterns for instanceof including nested record patterns. -------------------------------------------------------------------------------- /Chapter04/P97_RecordPatternInstanceof/src/main/java/modern/challenge/Appointment.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | import java.time.LocalDate; 4 | 5 | public record Appointment(LocalDate date, Doctor doctor) {} 6 | -------------------------------------------------------------------------------- /Chapter04/P97_RecordPatternInstanceof/src/main/java/modern/challenge/Doctor.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record Doctor(String name, String specialty) implements Staff {} 4 | -------------------------------------------------------------------------------- /Chapter04/P97_RecordPatternInstanceof/src/main/java/modern/challenge/Patient.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record Patient(String name, int npi, Appointment appointment) {} 4 | -------------------------------------------------------------------------------- /Chapter04/P97_RecordPatternInstanceof/src/main/java/modern/challenge/Resident.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record Resident(String name, Doctor doctor) implements Staff {} 4 | -------------------------------------------------------------------------------- /Chapter04/P97_RecordPatternInstanceof/src/main/java/modern/challenge/Staff.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public interface Staff {} 4 | -------------------------------------------------------------------------------- /Chapter04/P98_RecordPatternSwitch/README.md: -------------------------------------------------------------------------------- 1 | # Introducing record pattern for switch: 2 | Write a bunch of examples that introduce record patterns for switch. -------------------------------------------------------------------------------- /Chapter04/P98_RecordPatternSwitch/src/main/java/modern/challenge/Appointment.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | import java.time.LocalDate; 4 | 5 | public record Appointment(LocalDate date, Doctor doctor) {} 6 | -------------------------------------------------------------------------------- /Chapter04/P98_RecordPatternSwitch/src/main/java/modern/challenge/Doctor.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record Doctor(String name, String specialty) implements Staff {} 4 | -------------------------------------------------------------------------------- /Chapter04/P98_RecordPatternSwitch/src/main/java/modern/challenge/Patient.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record Patient(String name, int npi, Appointment appointment) {} 4 | -------------------------------------------------------------------------------- /Chapter04/P98_RecordPatternSwitch/src/main/java/modern/challenge/Resident.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record Resident(String name, Doctor doctor) implements Staff {} 4 | -------------------------------------------------------------------------------- /Chapter04/P98_RecordPatternSwitch/src/main/java/modern/challenge/Staff.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public interface Staff {} 4 | -------------------------------------------------------------------------------- /Chapter04/P99_RecordPatternInstanceofGuarded/README.md: -------------------------------------------------------------------------------- 1 | # Tackling guarded record patterns: 2 | Write several snippets of code to exemplify guarded record patterns (guarded conditions based on the binding variables). -------------------------------------------------------------------------------- /Chapter04/P99_RecordPatternInstanceofGuarded/src/main/java/modern/challenge/Appointment.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | import java.time.LocalDate; 4 | 5 | public record Appointment(LocalDate date, Doctor doctor) {} 6 | -------------------------------------------------------------------------------- /Chapter04/P99_RecordPatternInstanceofGuarded/src/main/java/modern/challenge/Doctor.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record Doctor(String name, String specialty) implements Staff {} 4 | -------------------------------------------------------------------------------- /Chapter04/P99_RecordPatternInstanceofGuarded/src/main/java/modern/challenge/Patient.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record Patient(String name, int npi, Appointment appointment) {} 4 | -------------------------------------------------------------------------------- /Chapter04/P99_RecordPatternInstanceofGuarded/src/main/java/modern/challenge/Resident.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record Resident(String name, Doctor doctor) implements Staff {} 4 | -------------------------------------------------------------------------------- /Chapter04/P99_RecordPatternInstanceofGuarded/src/main/java/modern/challenge/Staff.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public interface Staff {} 4 | -------------------------------------------------------------------------------- /Chapter04/P99_RecordPatternSwitchGuarded/README.md: -------------------------------------------------------------------------------- 1 | # Tackling guarded record patterns: 2 | Write several snippets of code to exemplify guarded record patterns (guarded conditions based on the binding variables). -------------------------------------------------------------------------------- /Chapter04/P99_RecordPatternSwitchGuarded/src/main/java/modern/challenge/Appointment.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | import java.time.LocalDate; 4 | 5 | public record Appointment(LocalDate date, Doctor doctor) {} 6 | -------------------------------------------------------------------------------- /Chapter04/P99_RecordPatternSwitchGuarded/src/main/java/modern/challenge/Doctor.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record Doctor(String name, String specialty) implements Staff {} 4 | -------------------------------------------------------------------------------- /Chapter04/P99_RecordPatternSwitchGuarded/src/main/java/modern/challenge/Patient.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record Patient(String name, int npi, Appointment appointment) {} 4 | -------------------------------------------------------------------------------- /Chapter04/P99_RecordPatternSwitchGuarded/src/main/java/modern/challenge/Resident.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record Resident(String name, Doctor doctor) implements Staff {} 4 | -------------------------------------------------------------------------------- /Chapter04/P99_RecordPatternSwitchGuarded/src/main/java/modern/challenge/Staff.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public interface Staff {} 4 | -------------------------------------------------------------------------------- /Chapter05/P108_VectorTerminology/README.md: -------------------------------------------------------------------------------- 1 | # Covering Vector API structure and terminology: 2 | Explain with examples the Vector API terminology. Cover notions such as element type, shape, species, lanes, and so on. -------------------------------------------------------------------------------- /Chapter05/P108_VectorTerminology/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module P108_VectorTerminology { 2 | requires jdk.incubator.vector; 3 | } 4 | -------------------------------------------------------------------------------- /Chapter05/P109_SimpleSummingArrays/README.md: -------------------------------------------------------------------------------- 1 | # Summing two arrays via Vector API: 2 | Write an application that uses Vector API for summing up two Java arrays. -------------------------------------------------------------------------------- /Chapter05/P109_SimpleSummingArrays/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module P109_SimpleSummingArrays { 2 | requires jdk.incubator.vector; 3 | } 4 | -------------------------------------------------------------------------------- /Chapter05/P109_SummingArrays/README.md: -------------------------------------------------------------------------------- 1 | # Summing two arrays via Vector API: 2 | Write an application that uses Vector API for summing up two Java arrays. -------------------------------------------------------------------------------- /Chapter05/P109_SummingArrays/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module P109_SummingArrays { 2 | requires jdk.incubator.vector; 3 | } 4 | -------------------------------------------------------------------------------- /Chapter05/P110_SummingArraysUnrolled/README.md: -------------------------------------------------------------------------------- 1 | # Summing two arrays unrolled via Vector API: 2 | Write an application that uses Vector API for summing two Java arrays using the unrolled technique. -------------------------------------------------------------------------------- /Chapter05/P110_SummingArraysUnrolled/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module P110_SummingArraysUnrolled { 2 | requires jdk.incubator.vector; 3 | } 4 | -------------------------------------------------------------------------------- /Chapter05/P111_BenchmarkVectors/README.md: -------------------------------------------------------------------------------- 1 | # Benchmarking Vector API: 2 | Consider two given arrays, x[], y[]. Write an application that benchmark the computation z[] = x[] + y[], w[] = x[] * z[] * y[], k[] = z[] + w[] * y[] using plain Java and Vector API. -------------------------------------------------------------------------------- /Chapter05/P111_BenchmarkVectors/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module P111_BenchmarkVectors { 2 | requires jdk.incubator.vector; 3 | requires jmh.generator.annprocess; 4 | requires jmh.core; 5 | } 6 | -------------------------------------------------------------------------------- /Chapter05/P112_VectorApiAndFma/README.md: -------------------------------------------------------------------------------- 1 | # Applying Vector API to compute FMA: 2 | Provide a Vector API implementation of the famous Fused Multiply Add (FMA). -------------------------------------------------------------------------------- /Chapter05/P112_VectorApiAndFma/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module P112_VectorApiAndFma { 2 | requires jdk.incubator.vector; 3 | } 4 | -------------------------------------------------------------------------------- /Chapter05/P113_MultiplyingMatricesVectorApi/README.md: -------------------------------------------------------------------------------- 1 | # Multiplying matrices via Vector API: 2 | Write a Vector API implementation for multiplying two matrices. -------------------------------------------------------------------------------- /Chapter05/P113_MultiplyingMatricesVectorApi/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module P113_MultiplyingMatricesVectorApi { 2 | requires jdk.incubator.vector; 3 | } 4 | -------------------------------------------------------------------------------- /Chapter05/P114_NegativeEffectVectorApi/README.md: -------------------------------------------------------------------------------- 1 | # Hooking the image negative filter with Vector API: 2 | Write a program that uses Vector API to apply the negative filter to an image. -------------------------------------------------------------------------------- /Chapter05/P114_NegativeEffectVectorApi/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter05/P114_NegativeEffectVectorApi/image.png -------------------------------------------------------------------------------- /Chapter05/P114_NegativeEffectVectorApi/image_negative.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter05/P114_NegativeEffectVectorApi/image_negative.png -------------------------------------------------------------------------------- /Chapter05/P114_NegativeEffectVectorApi/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module P114_NegativeEffectVectorApi { 2 | requires jdk.incubator.vector; 3 | requires java.desktop; 4 | } 5 | -------------------------------------------------------------------------------- /Chapter05/P115_FactoryMethodsForCollections/README.md: -------------------------------------------------------------------------------- 1 | # Dissecting factory methods for collections: 2 | Exemplify several approaches for creating unmodifiable/immutable maps, lists, and sets in Java. -------------------------------------------------------------------------------- /Chapter05/P116_StreamToList/README.md: -------------------------------------------------------------------------------- 1 | # Getting a list from a stream: 2 | Provide several snippets of code useful for collecting Stream content into a Java List. -------------------------------------------------------------------------------- /Chapter05/P116_StreamToList/src/main/java/modern/challenge/MelonMarket.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | import java.util.List; 4 | 5 | public record MelonMarket(List melons) {} 6 | -------------------------------------------------------------------------------- /Chapter05/P116_StreamToList/src/main/java/modern/challenge/MelonRecord.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record MelonRecord(String type, float weight) {} 4 | -------------------------------------------------------------------------------- /Chapter05/P117_newHashMap/README.md: -------------------------------------------------------------------------------- 1 | # Handling map capacity: 2 | Explain what the capacity of a Java Map is and how it can be used to control the number of effective mappings. -------------------------------------------------------------------------------- /Chapter05/P118_SequencedCollectionsAddFirstLast/README.md: -------------------------------------------------------------------------------- 1 | # Tackling Sequenced Collections: 2 | Provide a deep dive into the JDK 21 Sequenced Collections API. Exemplify this API on your favorite Java collections and explain what the alternatives before this API are. -------------------------------------------------------------------------------- /Chapter05/P118_SequencedCollectionsGetFirstLast/README.md: -------------------------------------------------------------------------------- 1 | # Tackling Sequenced Collections: 2 | Provide a deep dive into the JDK 21 Sequenced Collections API. Exemplify this API on your favorite Java collections and explain what the alternatives before this API are. -------------------------------------------------------------------------------- /Chapter05/P118_SequencedCollectionsRemove/README.md: -------------------------------------------------------------------------------- 1 | # Tackling Sequenced Collections: 2 | Provide a deep dive into the JDK 21 Sequenced Collections API. Exemplify this API on your favorite Java collections and explain what the alternatives before this API are. -------------------------------------------------------------------------------- /Chapter05/P118_SequencedCollectionsReverse/README.md: -------------------------------------------------------------------------------- 1 | # Tackling Sequenced Collections: 2 | Provide a deep dive into the JDK 21 Sequenced Collections API. Exemplify this API on your favorite Java collections and explain what the alternatives before this API are. -------------------------------------------------------------------------------- /Chapter05/P119_TheRopeDS/README.md: -------------------------------------------------------------------------------- 1 | # Introducing the Rope data structure: 2 | Explain what the Rope data structure is and provide a Java implementation for its main operations (index, insert, delete, concatenation, and split). -------------------------------------------------------------------------------- /Chapter05/P120_TheSkipListDS/README.md: -------------------------------------------------------------------------------- 1 | # Introducing the Skip List data structure: 2 | Explain and exemplify the Skip List data structure. -------------------------------------------------------------------------------- /Chapter05/P121_TheKDTreeDS/README.md: -------------------------------------------------------------------------------- 1 | # Introducing the K-D-trees data structure: 2 | Provide a brief introduction of K-D Trees and a Java implementation for 2-D Trees. -------------------------------------------------------------------------------- /Chapter05/P122_TheZipperDS/README.md: -------------------------------------------------------------------------------- 1 | # Introducing the Zipper data structure: 2 | Explain and exemplify on a tree the Zipper data structure. -------------------------------------------------------------------------------- /Chapter05/P122_TheZipperDS/src/main/java/modern/challenge/zipper/Zippable.java: -------------------------------------------------------------------------------- 1 | package modern.challenge.zipper; 2 | 3 | import java.util.Collection; 4 | 5 | public interface Zippable { 6 | 7 | public Collection getChildren(); 8 | } 9 | -------------------------------------------------------------------------------- /Chapter05/P123_TheBinomialHeapDS/README.md: -------------------------------------------------------------------------------- 1 | # Introducing the Binomial Heap data structure: 2 | Provide a deep coverage of a Binomial Heap data structure. Explain its main operations and exemplify them in a Java implementation. -------------------------------------------------------------------------------- /Chapter05/P124_TheFibonacciHeapDS/README.md: -------------------------------------------------------------------------------- 1 | # Introducing the Fibonacci Heaps data structure: 2 | Explain and exemplify the Fibonacci Heap data structure. -------------------------------------------------------------------------------- /Chapter05/P125_ThePairingHeapDS/README.md: -------------------------------------------------------------------------------- 1 | # Introducing the Pairing Heaps data structure: 2 | Explain and exemplify the Pairing Heap data structure. -------------------------------------------------------------------------------- /Chapter05/P126_TheHuffmanCodingDS/README.md: -------------------------------------------------------------------------------- 1 | # Introducing the Huffman Coding data structure: 2 | The Huffman Coding algorithm was developed by David A. Huffman in 1950. Explain its usage and exemplify it via a Java implementation. -------------------------------------------------------------------------------- /Chapter05/P127_TheSplayTreeDS/README.md: -------------------------------------------------------------------------------- 1 | # Introducing the Splay Tree data structure: 2 | A Splay Tree is a flavor of Binary Search Tree (BST). Explain what its particularities are and provide an implementation of its main operations. -------------------------------------------------------------------------------- /Chapter05/P128_TheIntervalTreeDS/README.md: -------------------------------------------------------------------------------- 1 | # Introducing the Interval Tree data structure: 2 | An Interval Tree is another flavor of Binary Search Tree (BST). Highlight its usage and exemplify it via a Java implementation. -------------------------------------------------------------------------------- /Chapter05/P129_TheUnrolledLinkedListDS_1/README.md: -------------------------------------------------------------------------------- 1 | # Introducing the Unrolled Linked List data structure: 2 | Explain and exemplify the Unrolled Linked List data structure. -------------------------------------------------------------------------------- /Chapter05/P129_TheUnrolledLinkedListDS_2/README.md: -------------------------------------------------------------------------------- 1 | # Introducing the Unrolled Linked List data structure: 2 | Explain and exemplify the Unrolled Linked List data structure. -------------------------------------------------------------------------------- /Chapter05/P130_TheJoinAlgorithms/README.md: -------------------------------------------------------------------------------- 1 | # Implementing joins algorithms: 2 | There are three famous join algorithms: Nested Loop Join, Hash Join, and Sort Merge Join. Explain and exemplify each of them on two tables that are involved in a one-to-many relationship. -------------------------------------------------------------------------------- /Chapter05/P130_TheJoinAlgorithms/src/main/java/modern/challenge/Author.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record Author(int authorId, String name) {} 4 | -------------------------------------------------------------------------------- /Chapter05/P130_TheJoinAlgorithms/src/main/java/modern/challenge/Book.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record Book(int bookId, String title, int authorId) {} 4 | -------------------------------------------------------------------------------- /Chapter05/P130_TheJoinAlgorithms/src/main/java/modern/challenge/ResultRow.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record ResultRow(int authorId, String name, String title, int bookId) {} 4 | -------------------------------------------------------------------------------- /Chapter06/P131_ObjectToByteArraySer/README.md: -------------------------------------------------------------------------------- 1 | # Serializing objects to byte arrays: 2 | Write a Java application that exposes two helper methods for serializing/deserializing objects to/from byte[]. -------------------------------------------------------------------------------- /Chapter06/P132_ObjectToStringSer/README.md: -------------------------------------------------------------------------------- 1 | # Serializing objects to strings: 2 | Write a Java application that exposes two helper methods for serializing/deserializing objects to/from String. -------------------------------------------------------------------------------- /Chapter06/P133_ObjectToXML/README.md: -------------------------------------------------------------------------------- 1 | # Serializing objects to XML: 2 | Exemplify at least two approaches for serializing/deserializing objects to/from XML format. -------------------------------------------------------------------------------- /Chapter06/P135_PatternBasedStreamGlobalFilter/README.md: -------------------------------------------------------------------------------- 1 | # Implementing a custom pattern-based ObjectInputFilter: 2 | Provide an example of implementing and setting a custom pattern-based filter via the ObjectInputFilter API. -------------------------------------------------------------------------------- /Chapter06/P135_PatternBasedStreamSpecificFilter/README.md: -------------------------------------------------------------------------------- 1 | # Implementing a custom pattern-based ObjectInputFilter: 2 | Provide an example of implementing and setting a custom pattern-based filter via the ObjectInputFilter API. -------------------------------------------------------------------------------- /Chapter06/P136_CustomClassFilter/README.md: -------------------------------------------------------------------------------- 1 | # Implementing a custom class ObjectInputFilter: 2 | Exemplify the creation of an ObjectInputFilter via a class implementation. -------------------------------------------------------------------------------- /Chapter06/P137_CustomMethodFilter1/README.md: -------------------------------------------------------------------------------- 1 | # Implementing a custom method ObjectInputFilter: 2 | Exemplify the creation of an ObjectInputFilter via a method implementation. -------------------------------------------------------------------------------- /Chapter06/P137_CustomMethodFilter2/README.md: -------------------------------------------------------------------------------- 1 | # Implementing a custom method ObjectInputFilter: 2 | Exemplify the creation of an ObjectInputFilter via a method implementation. -------------------------------------------------------------------------------- /Chapter06/P138_CustomLambdaFilter/README.md: -------------------------------------------------------------------------------- 1 | # Implementing a custom lambda ObjectInputFilter: 2 | Exemplify the creation of an ObjectInputFilter via a lambda expression. -------------------------------------------------------------------------------- /Chapter06/P141_JDK17CustomFilter/README.md: -------------------------------------------------------------------------------- 1 | # Introducing JDK 17 easy filter creation: 2 | Explain and exemplify the usage of the JDK 17 allowFilter() and rejectFilter() methods. -------------------------------------------------------------------------------- /Chapter06/P142_JDK17CustomFilterFactory/README.md: -------------------------------------------------------------------------------- 1 | # Tackling context-specific deserialization filters: 2 | Explain and exemplify the usage of JDK 17 Filter Factories. -------------------------------------------------------------------------------- /Chapter06/P143_MonitoringDeserializationJfr/README.md: -------------------------------------------------------------------------------- 1 | # Monitoring Deserialization via JFR: 2 | Exemplify the usage of Java Flight Recorder (JFR) for monitoring a deserialization event. -------------------------------------------------------------------------------- /Chapter06/P143_MonitoringDeserializationJfr/recording.jfr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter06/P143_MonitoringDeserializationJfr/recording.jfr -------------------------------------------------------------------------------- /Chapter07/JDK 20/P144_EngagingJNI/jni/cpp/math.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter07/JDK 20/P144_EngagingJNI/jni/cpp/math.dll -------------------------------------------------------------------------------- /Chapter07/JDK 20/P144_EngagingJNI/jni/cpp/modern_challenge_Main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter07/JDK 20/P144_EngagingJNI/jni/cpp/modern_challenge_Main.o -------------------------------------------------------------------------------- /Chapter07/JDK 20/P145_EngagingJNA/README.md: -------------------------------------------------------------------------------- 1 | # Introducing Java Native Access (JNA): 2 | Write a Java application that calls a C/C++ native foreign function via the JNA API. 3 | 4 | ## Using JDK 20 -------------------------------------------------------------------------------- /Chapter07/JDK 20/P145_EngagingJNA/jna/cpp/Arithmetic.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter07/JDK 20/P145_EngagingJNA/jna/cpp/Arithmetic.o -------------------------------------------------------------------------------- /Chapter07/JDK 20/P145_EngagingJNA/jna/cpp/math.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter07/JDK 20/P145_EngagingJNA/jna/cpp/math.dll -------------------------------------------------------------------------------- /Chapter07/JDK 20/P145_EngagingJNA/src/main/java/modern/challenge/SimpleMath.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | import com.sun.jna.Library; 4 | 5 | public interface SimpleMath extends Library { 6 | long sumTwoInt(int x, int y); 7 | } -------------------------------------------------------------------------------- /Chapter07/JDK 20/P145_EngagingJNA/src/main/java/modern/challenge/cpp/Arithmetic.h: -------------------------------------------------------------------------------- 1 | #ifndef FUNCTIONS_H_INCLUDED 2 | #define FUNCTIONS_H_INCLUDED 3 | 4 | long sumTwoInt(int x, int y); // Function prototype, its declaration 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /Chapter07/JDK 20/P146_EngagingJNR/README.md: -------------------------------------------------------------------------------- 1 | # Introducing Java Native Runtime (JNR): 2 | Write a Java application that calls a C/C++ native foreign function via the JNR API. 3 | 4 | ## Using JDK 20 -------------------------------------------------------------------------------- /Chapter07/JDK 20/P146_EngagingJNR/jnr/cpp/Arithmetic.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter07/JDK 20/P146_EngagingJNR/jnr/cpp/Arithmetic.o -------------------------------------------------------------------------------- /Chapter07/JDK 20/P146_EngagingJNR/jnr/cpp/math.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter07/JDK 20/P146_EngagingJNR/jnr/cpp/math.dll -------------------------------------------------------------------------------- /Chapter07/JDK 20/P146_EngagingJNR/src/main/java/modern/challenge/SimpleMath.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | import jnr.ffi.annotations.IgnoreError; 4 | 5 | public interface SimpleMath { 6 | @IgnoreError 7 | long sumTwoInt(int x, int y); 8 | } -------------------------------------------------------------------------------- /Chapter07/JDK 20/P146_EngagingJNR/src/main/java/modern/challenge/cpp/Arithmetic.h: -------------------------------------------------------------------------------- 1 | #ifndef FUNCTIONS_H_INCLUDED 2 | #define FUNCTIONS_H_INCLUDED 3 | 4 | long sumTwoInt(int x, int y); // Function prototype, its declaration 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /Chapter07/JDK 20/P149_ArenaMemorySegment/README.md: -------------------------------------------------------------------------------- 1 | # Introducing Arena and MemorySegment: 2 | Explain and exemplify via snippets of code the Arena and MemorySegment APIs. 3 | 4 | ## Using JDK 20 -------------------------------------------------------------------------------- /Chapter07/JDK 20/P150_MemorySegmentAndArray/README.md: -------------------------------------------------------------------------------- 1 | # Allocating arrays into memory segments: 2 | Write several approaches for allocating arrays into memory segments (via Arena and MemorySegment). 3 | 4 | ## Using JDK 20 -------------------------------------------------------------------------------- /Chapter07/JDK 20/P150_MemorySegmentAndArray/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module P150_VectorTerminology { 2 | requires jdk.incubator.vector; 3 | } 4 | -------------------------------------------------------------------------------- /Chapter07/JDK 20/P151_MemorySegmentAndAddress/README.md: -------------------------------------------------------------------------------- 1 | # Understanding addresses (pointers): 2 | Exemplify the usage of memory addresses (pointers) in Java (ValueLayout.ADDRESS). 3 | 4 | ## Using JDK 20 -------------------------------------------------------------------------------- /Chapter07/JDK 20/P152_IntroSequenceLayout/README.md: -------------------------------------------------------------------------------- 1 | # Introducing sequence layout: 2 | Explain and exemplify the usage of sequence layout. Moreover, introduce the PathElement and VarHandle APIs. 3 | 4 | ## Using JDK 20 -------------------------------------------------------------------------------- /Chapter07/JDK 20/P153_MemorySegmentAndStruct/README.md: -------------------------------------------------------------------------------- 1 | # Shaping C-like structs into memory segments: 2 | Exemplify the approach of shaping C-like structs via Java memory layouts (StructLayout). 3 | 4 | ## Using JDK 20 -------------------------------------------------------------------------------- /Chapter07/JDK 20/P154_MemorySegmentAndUnion/README.md: -------------------------------------------------------------------------------- 1 | # Shaping C-like unions into memory segments: 2 | Exemplify the approach of shaping C-like unions via Java memory layouts (UnionLayout). 3 | 4 | ## Using JDK 20 -------------------------------------------------------------------------------- /Chapter07/JDK 20/P155_IntroPaddingLayout/README.md: -------------------------------------------------------------------------------- 1 | # Introducing PaddingLayout: 2 | Provide a detailed explanation and meaningful examples for explaining padding layout (introduce size, alignment, stride, padding, and order of bytes). 3 | 4 | ## Using JDK 20 -------------------------------------------------------------------------------- /Chapter07/JDK 20/P156_CopyingSlicingMemorySegments/README.md: -------------------------------------------------------------------------------- 1 | # Copying and slicing memory segments: 2 | Exemplify different approaches for copying and slicing parts of a memory segment including asOverlappingSlice() and segmentOffset(). 3 | 4 | ## Using JDK 20 -------------------------------------------------------------------------------- /Chapter07/JDK 20/P156_CopyingSlicingMemorySegments/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module P156_VectorTerminology { 2 | requires jdk.incubator.vector; 3 | } 4 | -------------------------------------------------------------------------------- /Chapter07/JDK 20/P157_WorkingWithSlicingAllocator/README.md: -------------------------------------------------------------------------------- 1 | # Tackling the slicing allocator: 2 | Exemplify the usage of the slicing allocator (SegmentAllocator). 3 | 4 | ## Using JDK 20 -------------------------------------------------------------------------------- /Chapter07/JDK 20/P158_IntroSliceHandle/README.md: -------------------------------------------------------------------------------- 1 | # Introducing slice handle: 2 | Explain and exemplify the usage of sliceHandle(). 3 | 4 | ## Using JDK 20 -------------------------------------------------------------------------------- /Chapter07/JDK 20/P159_IntroLayoutFlatenning/README.md: -------------------------------------------------------------------------------- 1 | # Introducing layout flattening: 2 | Consider a hierarchical memory layout (for instance, two nested sequence layouts). Explain and exemplify how to flatten this model. 3 | 4 | ## Using JDK 20 -------------------------------------------------------------------------------- /Chapter07/JDK 20/P160_IntroLayoutReshaping/README.md: -------------------------------------------------------------------------------- 1 | # Introducing layout reshaping: 2 | Provide an example that reshapes a hierarchical sequence layout. 3 | 4 | ## Using JDK 20 -------------------------------------------------------------------------------- /Chapter07/JDK 20/P161_IntroLayoutSpreader/README.md: -------------------------------------------------------------------------------- 1 | # Introducing layout spreader: 2 | Provide a brief explanation and a simple example of using layout spreader (asSpreader()). 3 | 4 | ## Using JDK 20 -------------------------------------------------------------------------------- /Chapter07/JDK 20/P163_StreamingMemorySegment/README.md: -------------------------------------------------------------------------------- 1 | # Streaming memory segments: 2 | Write several snippets of code for combining memory segments with the Java Stream API. 3 | 4 | ## Using JDK 20 -------------------------------------------------------------------------------- /Chapter07/JDK 20/P164_ArenaMappedMemorySegment/README.md: -------------------------------------------------------------------------------- 1 | # Tackling mapped memory segments: 2 | Provide a brief introduction of mapped memory segments and exemplify them in Java code. 3 | 4 | ## Using JDK 20 -------------------------------------------------------------------------------- /Chapter07/JDK 20/P164_MappedMemorySegment/README.md: -------------------------------------------------------------------------------- 1 | # Tackling mapped memory segments: 2 | Provide a brief introduction of mapped memory segments and exemplify them in Java code. 3 | 4 | ## Using JDK 20 -------------------------------------------------------------------------------- /Chapter07/JDK 20/P165_CallingGetpid/README.md: -------------------------------------------------------------------------------- 1 | # Introducing Foreign Linker API: 2 | Provide a brief description of Foreign Linker API including Linker, SymbolLookup, downcall, and upcall. 3 | 4 | ## Using JDK 20 -------------------------------------------------------------------------------- /Chapter07/JDK 20/P166_CallingSumTwoInt/lib/cpp/Arithmetic.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter07/JDK 20/P166_CallingSumTwoInt/lib/cpp/Arithmetic.o -------------------------------------------------------------------------------- /Chapter07/JDK 20/P166_CallingSumTwoInt/lib/cpp/math.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter07/JDK 20/P166_CallingSumTwoInt/lib/cpp/math.dll -------------------------------------------------------------------------------- /Chapter07/JDK 20/P166_CallingSumTwoInt/src/main/java/modern/challenge/cpp/Arithmetic.h: -------------------------------------------------------------------------------- 1 | #ifndef FUNCTIONS_H_INCLUDED 2 | #define FUNCTIONS_H_INCLUDED 3 | 4 | long sumTwoInt(int x, int y); // Function prototype, its declaration 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /Chapter07/JDK 20/P167_CallingModf/README.md: -------------------------------------------------------------------------------- 1 | # Calling the modf() foreign function: 2 | Use Foreign Linker API to call the modf() foreign function – this function is part of the C standard library. 3 | 4 | ## Using JDK 20 -------------------------------------------------------------------------------- /Chapter07/JDK 20/P168_CallingStrcat/README.md: -------------------------------------------------------------------------------- 1 | # Calling the strcat() foreign function: 2 | Use Foreign Linker API to call the strcat() foreign function – this function is part of the C standard library. 3 | 4 | ## Using JDK 20 -------------------------------------------------------------------------------- /Chapter07/JDK 20/P169_CallingBsearch/README.md: -------------------------------------------------------------------------------- 1 | # Calling the bsearch() foreign function: 2 | Use Foreign Linker API to call the bsearch() foreign function – this function is part of the C standard library. 3 | 4 | ## Using JDK 20 -------------------------------------------------------------------------------- /Chapter07/JDK 20/P171_JextractAndModf/README.md: -------------------------------------------------------------------------------- 1 | # Generating native binding for modf(): 2 | Exemplify the combination of Jextract and Foreign Linker API to call the modf() foreign function. 3 | 4 | ## Using JDK 20 -------------------------------------------------------------------------------- /Chapter07/JDK 21/P144_EngagingJNI/jni/cpp/math.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter07/JDK 21/P144_EngagingJNI/jni/cpp/math.dll -------------------------------------------------------------------------------- /Chapter07/JDK 21/P144_EngagingJNI/jni/cpp/modern_challenge_Main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter07/JDK 21/P144_EngagingJNI/jni/cpp/modern_challenge_Main.o -------------------------------------------------------------------------------- /Chapter07/JDK 21/P145_EngagingJNA/README.md: -------------------------------------------------------------------------------- 1 | # Introducing Java Native Access (JNA): 2 | Write a Java application that calls a C/C++ native foreign function via the JNA API. 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 21/P145_EngagingJNA/jna/cpp/Arithmetic.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter07/JDK 21/P145_EngagingJNA/jna/cpp/Arithmetic.o -------------------------------------------------------------------------------- /Chapter07/JDK 21/P145_EngagingJNA/jna/cpp/math.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter07/JDK 21/P145_EngagingJNA/jna/cpp/math.dll -------------------------------------------------------------------------------- /Chapter07/JDK 21/P145_EngagingJNA/src/main/java/modern/challenge/SimpleMath.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | import com.sun.jna.Library; 4 | 5 | public interface SimpleMath extends Library { 6 | long sumTwoInt(int x, int y); 7 | } -------------------------------------------------------------------------------- /Chapter07/JDK 21/P145_EngagingJNA/src/main/java/modern/challenge/cpp/Arithmetic.h: -------------------------------------------------------------------------------- 1 | #ifndef FUNCTIONS_H_INCLUDED 2 | #define FUNCTIONS_H_INCLUDED 3 | 4 | long sumTwoInt(int x, int y); // Function prototype, its declaration 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /Chapter07/JDK 21/P146_EngagingJNR/README.md: -------------------------------------------------------------------------------- 1 | # Introducing Java Native Runtime (JNR): 2 | Write a Java application that calls a C/C++ native foreign function via the JNR API. 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 21/P146_EngagingJNR/jnr/cpp/Arithmetic.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter07/JDK 21/P146_EngagingJNR/jnr/cpp/Arithmetic.o -------------------------------------------------------------------------------- /Chapter07/JDK 21/P146_EngagingJNR/jnr/cpp/math.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter07/JDK 21/P146_EngagingJNR/jnr/cpp/math.dll -------------------------------------------------------------------------------- /Chapter07/JDK 21/P146_EngagingJNR/src/main/java/modern/challenge/SimpleMath.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | import jnr.ffi.annotations.IgnoreError; 4 | 5 | public interface SimpleMath { 6 | @IgnoreError 7 | long sumTwoInt(int x, int y); 8 | } -------------------------------------------------------------------------------- /Chapter07/JDK 21/P146_EngagingJNR/src/main/java/modern/challenge/cpp/Arithmetic.h: -------------------------------------------------------------------------------- 1 | #ifndef FUNCTIONS_H_INCLUDED 2 | #define FUNCTIONS_H_INCLUDED 3 | 4 | long sumTwoInt(int x, int y); // Function prototype, its declaration 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /Chapter07/JDK 21/P149_ArenaMemorySegment/README.md: -------------------------------------------------------------------------------- 1 | # Introducing Arena and MemorySegment: 2 | Explain and exemplify via snippets of code the Arena and MemorySegment APIs. 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 21/P150_MemorySegmentAndArray/README.md: -------------------------------------------------------------------------------- 1 | # Allocating arrays into memory segments: 2 | Write several approaches for allocating arrays into memory segments (via Arena and MemorySegment). 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 21/P150_MemorySegmentAndArray/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module P150_VectorTerminology { 2 | requires jdk.incubator.vector; 3 | } 4 | -------------------------------------------------------------------------------- /Chapter07/JDK 21/P151_MemorySegmentAndAddress/README.md: -------------------------------------------------------------------------------- 1 | # Understanding addresses (pointers): 2 | Exemplify the usage of memory addresses (pointers) in Java (ValueLayout.ADDRESS). 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 21/P152_IntroSequenceLayout/README.md: -------------------------------------------------------------------------------- 1 | # Introducing sequence layout: 2 | Explain and exemplify the usage of sequence layout. Moreover, introduce the PathElement and VarHandle APIs. 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 21/P153_MemorySegmentAndStruct/README.md: -------------------------------------------------------------------------------- 1 | # Shaping C-like structs into memory segments: 2 | Exemplify the approach of shaping C-like structs via Java memory layouts (StructLayout). 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 21/P154_MemorySegmentAndUnion/README.md: -------------------------------------------------------------------------------- 1 | # Shaping C-like unions into memory segments: 2 | Exemplify the approach of shaping C-like unions via Java memory layouts (UnionLayout). 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 21/P155_IntroPaddingLayout/README.md: -------------------------------------------------------------------------------- 1 | # Introducing PaddingLayout: 2 | Provide a detailed explanation and meaningful examples for explaining padding layout (introduce size, alignment, stride, padding, and order of bytes). 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 21/P156_CopyingSlicingMemorySegments/README.md: -------------------------------------------------------------------------------- 1 | # Copying and slicing memory segments: 2 | Exemplify different approaches for copying and slicing parts of a memory segment including asOverlappingSlice() and segmentOffset(). 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 21/P156_CopyingSlicingMemorySegments/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module P156_VectorTerminology { 2 | requires jdk.incubator.vector; 3 | } 4 | -------------------------------------------------------------------------------- /Chapter07/JDK 21/P157_WorkingWithSlicingAllocator/README.md: -------------------------------------------------------------------------------- 1 | # Tackling the slicing allocator: 2 | Exemplify the usage of the slicing allocator (SegmentAllocator). 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 21/P158_IntroSliceHandle/README.md: -------------------------------------------------------------------------------- 1 | # Introducing slice handle: 2 | Explain and exemplify the usage of sliceHandle(). 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 21/P159_IntroLayoutFlatenning/README.md: -------------------------------------------------------------------------------- 1 | # Introducing layout flattening: 2 | Consider a hierarchical memory layout (for instance, two nested sequence layouts). Explain and exemplify how to flatten this model. 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 21/P160_IntroLayoutReshaping/README.md: -------------------------------------------------------------------------------- 1 | # Introducing layout reshaping: 2 | Provide an example that reshapes a hierarchical sequence layout. 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 21/P161_IntroLayoutSpreader/README.md: -------------------------------------------------------------------------------- 1 | # Introducing layout spreader: 2 | Provide a brief explanation and a simple example of using layout spreader (asSpreader()). 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 21/P163_StreamingMemorySegment/README.md: -------------------------------------------------------------------------------- 1 | # Streaming memory segments: 2 | Write several snippets of code for combining memory segments with the Java Stream API. 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 21/P164_ArenaMappedMemorySegment/README.md: -------------------------------------------------------------------------------- 1 | # Tackling mapped memory segments: 2 | Provide a brief introduction of mapped memory segments and exemplify them in Java code. 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 21/P164_MappedMemorySegment/README.md: -------------------------------------------------------------------------------- 1 | # Tackling mapped memory segments: 2 | Provide a brief introduction of mapped memory segments and exemplify them in Java code. 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 21/P165_CallingGetpid/README.md: -------------------------------------------------------------------------------- 1 | # Introducing Foreign Linker API: 2 | Provide a brief description of Foreign Linker API including Linker, SymbolLookup, downcall, and upcall. 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 21/P166_CallingSumTwoInt/lib/cpp/Arithmetic.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter07/JDK 21/P166_CallingSumTwoInt/lib/cpp/Arithmetic.o -------------------------------------------------------------------------------- /Chapter07/JDK 21/P166_CallingSumTwoInt/lib/cpp/math.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter07/JDK 21/P166_CallingSumTwoInt/lib/cpp/math.dll -------------------------------------------------------------------------------- /Chapter07/JDK 21/P166_CallingSumTwoInt/src/main/java/modern/challenge/cpp/Arithmetic.h: -------------------------------------------------------------------------------- 1 | #ifndef FUNCTIONS_H_INCLUDED 2 | #define FUNCTIONS_H_INCLUDED 3 | 4 | long sumTwoInt(int x, int y); // Function prototype, its declaration 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /Chapter07/JDK 21/P167_CallingModf/README.md: -------------------------------------------------------------------------------- 1 | # Calling the modf() foreign function: 2 | Use Foreign Linker API to call the modf() foreign function – this function is part of the C standard library. 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 21/P168_CallingStrcat/README.md: -------------------------------------------------------------------------------- 1 | # Calling the strcat() foreign function: 2 | Use Foreign Linker API to call the strcat() foreign function – this function is part of the C standard library. 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 21/P169_CallingBsearch/README.md: -------------------------------------------------------------------------------- 1 | # Calling the bsearch() foreign function: 2 | Use Foreign Linker API to call the bsearch() foreign function – this function is part of the C standard library. 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 21/P171_JextractAndModf/README.md: -------------------------------------------------------------------------------- 1 | Generating native binding for modf(): 2 | Exemplify the combination of Jextract and Foreign Linker API to call the modf() foreign function. 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 21/P171_JextractAndModf/includes.txt: -------------------------------------------------------------------------------- 1 | #### Extracted from: C:\MinGW64\mingw64\x86_64-w64-mingw32\include\crtdefs.h 2 | --include-function fmodf # header: C:\MinGW64\mingw64\x86_64-w64-mingw32\include\math.h -------------------------------------------------------------------------------- /Chapter07/JDK 22/P144_EngagingJNI/jni/cpp/math.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter07/JDK 22/P144_EngagingJNI/jni/cpp/math.dll -------------------------------------------------------------------------------- /Chapter07/JDK 22/P144_EngagingJNI/jni/cpp/modern_challenge_Main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter07/JDK 22/P144_EngagingJNI/jni/cpp/modern_challenge_Main.o -------------------------------------------------------------------------------- /Chapter07/JDK 22/P145_EngagingJNA/README.md: -------------------------------------------------------------------------------- 1 | # Introducing Java Native Access (JNA): 2 | Write a Java application that calls a C/C++ native foreign function via the JNA API. 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 22/P145_EngagingJNA/jna/cpp/Arithmetic.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter07/JDK 22/P145_EngagingJNA/jna/cpp/Arithmetic.o -------------------------------------------------------------------------------- /Chapter07/JDK 22/P145_EngagingJNA/jna/cpp/math.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter07/JDK 22/P145_EngagingJNA/jna/cpp/math.dll -------------------------------------------------------------------------------- /Chapter07/JDK 22/P145_EngagingJNA/src/main/java/modern/challenge/SimpleMath.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | import com.sun.jna.Library; 4 | 5 | public interface SimpleMath extends Library { 6 | long sumTwoInt(int x, int y); 7 | } -------------------------------------------------------------------------------- /Chapter07/JDK 22/P145_EngagingJNA/src/main/java/modern/challenge/cpp/Arithmetic.h: -------------------------------------------------------------------------------- 1 | #ifndef FUNCTIONS_H_INCLUDED 2 | #define FUNCTIONS_H_INCLUDED 3 | 4 | long sumTwoInt(int x, int y); // Function prototype, its declaration 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /Chapter07/JDK 22/P146_EngagingJNR/README.md: -------------------------------------------------------------------------------- 1 | # Introducing Java Native Runtime (JNR): 2 | Write a Java application that calls a C/C++ native foreign function via the JNR API. 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 22/P146_EngagingJNR/jnr/cpp/Arithmetic.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter07/JDK 22/P146_EngagingJNR/jnr/cpp/Arithmetic.o -------------------------------------------------------------------------------- /Chapter07/JDK 22/P146_EngagingJNR/jnr/cpp/math.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter07/JDK 22/P146_EngagingJNR/jnr/cpp/math.dll -------------------------------------------------------------------------------- /Chapter07/JDK 22/P146_EngagingJNR/src/main/java/modern/challenge/SimpleMath.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | import jnr.ffi.annotations.IgnoreError; 4 | 5 | public interface SimpleMath { 6 | @IgnoreError 7 | long sumTwoInt(int x, int y); 8 | } -------------------------------------------------------------------------------- /Chapter07/JDK 22/P146_EngagingJNR/src/main/java/modern/challenge/cpp/Arithmetic.h: -------------------------------------------------------------------------------- 1 | #ifndef FUNCTIONS_H_INCLUDED 2 | #define FUNCTIONS_H_INCLUDED 3 | 4 | long sumTwoInt(int x, int y); // Function prototype, its declaration 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /Chapter07/JDK 22/P149_ArenaMemorySegment/README.md: -------------------------------------------------------------------------------- 1 | # Introducing Arena and MemorySegment: 2 | Explain and exemplify via snippets of code the Arena and MemorySegment APIs. 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 22/P150_MemorySegmentAndArray/README.md: -------------------------------------------------------------------------------- 1 | # Allocating arrays into memory segments: 2 | Write several approaches for allocating arrays into memory segments (via Arena and MemorySegment). 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 22/P150_MemorySegmentAndArray/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module P150_VectorTerminology { 2 | requires jdk.incubator.vector; 3 | } 4 | -------------------------------------------------------------------------------- /Chapter07/JDK 22/P151_MemorySegmentAndAddress/README.md: -------------------------------------------------------------------------------- 1 | # Understanding addresses (pointers): 2 | Exemplify the usage of memory addresses (pointers) in Java (ValueLayout.ADDRESS). 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 22/P152_IntroSequenceLayout/README.md: -------------------------------------------------------------------------------- 1 | # Introducing sequence layout: 2 | Explain and exemplify the usage of sequence layout. Moreover, introduce the PathElement and VarHandle APIs. 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 22/P153_MemorySegmentAndStruct/README.md: -------------------------------------------------------------------------------- 1 | # Shaping C-like structs into memory segments: 2 | Exemplify the approach of shaping C-like structs via Java memory layouts (StructLayout). 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 22/P154_MemorySegmentAndUnion/README.md: -------------------------------------------------------------------------------- 1 | # Shaping C-like unions into memory segments: 2 | Exemplify the approach of shaping C-like unions via Java memory layouts (UnionLayout). 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 22/P155_IntroPaddingLayout/README.md: -------------------------------------------------------------------------------- 1 | # Introducing PaddingLayout: 2 | Provide a detailed explanation and meaningful examples for explaining padding layout (introduce size, alignment, stride, padding, and order of bytes). 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 22/P156_CopyingSlicingMemorySegments/README.md: -------------------------------------------------------------------------------- 1 | # Copying and slicing memory segments: 2 | Exemplify different approaches for copying and slicing parts of a memory segment including asOverlappingSlice() and segmentOffset(). 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 22/P156_CopyingSlicingMemorySegments/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module P156_VectorTerminology { 2 | requires jdk.incubator.vector; 3 | } 4 | -------------------------------------------------------------------------------- /Chapter07/JDK 22/P157_WorkingWithSlicingAllocator/README.md: -------------------------------------------------------------------------------- 1 | # Tackling the slicing allocator: 2 | Exemplify the usage of the slicing allocator (SegmentAllocator). 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 22/P158_IntroSliceHandle/README.md: -------------------------------------------------------------------------------- 1 | # Introducing slice handle: 2 | Explain and exemplify the usage of sliceHandle(). 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 22/P159_IntroLayoutFlatenning/README.md: -------------------------------------------------------------------------------- 1 | # Introducing layout flattening: 2 | Consider a hierarchical memory layout (for instance, two nested sequence layouts). Explain and exemplify how to flatten this model. 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 22/P160_IntroLayoutReshaping/README.md: -------------------------------------------------------------------------------- 1 | # Introducing layout reshaping: 2 | Provide an example that reshapes a hierarchical sequence layout. 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 22/P161_IntroLayoutSpreader/README.md: -------------------------------------------------------------------------------- 1 | # Introducing layout spreader: 2 | Provide a brief explanation and a simple example of using layout spreader (asSpreader()). 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 22/P163_StreamingMemorySegment/README.md: -------------------------------------------------------------------------------- 1 | # Streaming memory segments: 2 | Write several snippets of code for combining memory segments with the Java Stream API. 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 22/P164_ArenaMappedMemorySegment/README.md: -------------------------------------------------------------------------------- 1 | # Tackling mapped memory segments: 2 | Provide a brief introduction of mapped memory segments and exemplify them in Java code. 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 22/P164_ArenaMappedMemorySegment/readme1712836518222.txt: -------------------------------------------------------------------------------- 1 | Hello -------------------------------------------------------------------------------- /Chapter07/JDK 22/P164_ArenaMappedMemorySegment/readme1712836518277.txt: -------------------------------------------------------------------------------- 1 | World -------------------------------------------------------------------------------- /Chapter07/JDK 22/P164_MappedMemorySegment/README.md: -------------------------------------------------------------------------------- 1 | # Tackling mapped memory segments: 2 | Provide a brief introduction of mapped memory segments and exemplify them in Java code. 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 22/P165_CallingGetpid/README.md: -------------------------------------------------------------------------------- 1 | # Introducing Foreign Linker API: 2 | Provide a brief description of Foreign Linker API including Linker, SymbolLookup, downcall, and upcall. 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 22/P166_CallingSumTwoInt/lib/cpp/Arithmetic.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter07/JDK 22/P166_CallingSumTwoInt/lib/cpp/Arithmetic.o -------------------------------------------------------------------------------- /Chapter07/JDK 22/P166_CallingSumTwoInt/lib/cpp/math.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter07/JDK 22/P166_CallingSumTwoInt/lib/cpp/math.dll -------------------------------------------------------------------------------- /Chapter07/JDK 22/P166_CallingSumTwoInt/src/main/java/modern/challenge/cpp/Arithmetic.h: -------------------------------------------------------------------------------- 1 | #ifndef FUNCTIONS_H_INCLUDED 2 | #define FUNCTIONS_H_INCLUDED 3 | 4 | long sumTwoInt(int x, int y); // Function prototype, its declaration 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /Chapter07/JDK 22/P167_CallingModf/README.md: -------------------------------------------------------------------------------- 1 | # Calling the modf() foreign function: 2 | Use Foreign Linker API to call the modf() foreign function – this function is part of the C standard library. 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter07/JDK 22/P168_CallingStrcat/README.md: -------------------------------------------------------------------------------- 1 | # Calling the strcat() foreign function: 2 | Use Foreign Linker API to call the strcat() foreign function – this function is part of the C standard library. 3 | 4 | ## Using JDK 21 -------------------------------------------------------------------------------- /Chapter08/P172_ElectricPanelHierarchy/src/main/java/modern/circuit/ElectricComponent.java: -------------------------------------------------------------------------------- 1 | package modern.circuit; 2 | 3 | public interface ElectricComponent {} -------------------------------------------------------------------------------- /Chapter08/P172_ElectricPanelHierarchy/src/main/java/modern/circuit/capacitor/Capacitor.java: -------------------------------------------------------------------------------- 1 | package modern.circuit.capacitor; 2 | 3 | import modern.circuit.ElectricComponent; 4 | 5 | public abstract class Capacitor implements ElectricComponent {} 6 | -------------------------------------------------------------------------------- /Chapter08/P172_ElectricPanelHierarchy/src/main/java/modern/circuit/capacitor/CeramicCapacitor.java: -------------------------------------------------------------------------------- 1 | package modern.circuit.capacitor; 2 | 3 | public class CeramicCapacitor extends Capacitor {} 4 | -------------------------------------------------------------------------------- /Chapter08/P172_ElectricPanelHierarchy/src/main/java/modern/circuit/capacitor/ElectrolyticCapacitor.java: -------------------------------------------------------------------------------- 1 | package modern.circuit.capacitor; 2 | 3 | public class ElectrolyticCapacitor extends Capacitor {} 4 | -------------------------------------------------------------------------------- /Chapter08/P172_ElectricPanelHierarchy/src/main/java/modern/circuit/resistor/CarbonResistor.java: -------------------------------------------------------------------------------- 1 | package modern.circuit.resistor; 2 | 3 | public class CarbonResistor extends Resistor {} 4 | -------------------------------------------------------------------------------- /Chapter08/P172_ElectricPanelHierarchy/src/main/java/modern/circuit/resistor/MetalFilmResistor.java: -------------------------------------------------------------------------------- 1 | package modern.circuit.resistor; 2 | 3 | public class MetalFilmResistor extends MetalResistor {} 4 | -------------------------------------------------------------------------------- /Chapter08/P172_ElectricPanelHierarchy/src/main/java/modern/circuit/resistor/MetalOxideResistor.java: -------------------------------------------------------------------------------- 1 | package modern.circuit.resistor; 2 | 3 | public class MetalOxideResistor extends MetalResistor {} 4 | -------------------------------------------------------------------------------- /Chapter08/P172_ElectricPanelHierarchy/src/main/java/modern/circuit/resistor/MetalResistor.java: -------------------------------------------------------------------------------- 1 | package modern.circuit.resistor; 2 | 3 | public class MetalResistor extends Resistor {} 4 | -------------------------------------------------------------------------------- /Chapter08/P172_ElectricPanelHierarchy/src/main/java/modern/circuit/transistor/BipolarTransistor.java: -------------------------------------------------------------------------------- 1 | package modern.circuit.transistor; 2 | 3 | public class BipolarTransistor extends Transistor {} 4 | -------------------------------------------------------------------------------- /Chapter08/P172_ElectricPanelHierarchy/src/main/java/modern/circuit/transistor/FieldEffectTransistor.java: -------------------------------------------------------------------------------- 1 | package modern.circuit.transistor; 2 | 3 | public class FieldEffectTransistor extends Transistor {} 4 | -------------------------------------------------------------------------------- /Chapter08/P172_ElectricPanelHierarchy/src/main/java/modern/circuit/transistor/Transistor.java: -------------------------------------------------------------------------------- 1 | package modern.circuit.transistor; 2 | 3 | import modern.circuit.ElectricComponent; 4 | 5 | public abstract class Transistor implements ElectricComponent {} 6 | -------------------------------------------------------------------------------- /Chapter08/P173_ClosedElectricPanelHierarchy/README.md: -------------------------------------------------------------------------------- 1 | # Closing the electrical panel before JDK 17: 2 | Use the Java features (for instance, final keyword and package-private hacks) to close this hierarchy (close to extension). -------------------------------------------------------------------------------- /Chapter08/P173_ClosedElectricPanelHierarchy/src/main/java/modern/circuit/ElectricComponent.java: -------------------------------------------------------------------------------- 1 | package modern.circuit; 2 | 3 | public interface ElectricComponent {} -------------------------------------------------------------------------------- /Chapter08/P173_ClosedElectricPanelHierarchy/src/main/java/modern/circuit/capacitor/CeramicCapacitor.java: -------------------------------------------------------------------------------- 1 | package modern.circuit.capacitor; 2 | 3 | public final class CeramicCapacitor extends Capacitor {} 4 | -------------------------------------------------------------------------------- /Chapter08/P173_ClosedElectricPanelHierarchy/src/main/java/modern/circuit/capacitor/ElectrolyticCapacitor.java: -------------------------------------------------------------------------------- 1 | package modern.circuit.capacitor; 2 | 3 | public final class ElectrolyticCapacitor extends Capacitor {} 4 | -------------------------------------------------------------------------------- /Chapter08/P173_ClosedElectricPanelHierarchy/src/main/java/modern/circuit/resistor/CarbonResistor.java: -------------------------------------------------------------------------------- 1 | package modern.circuit.resistor; 2 | 3 | public final class CarbonResistor extends Resistor {} 4 | -------------------------------------------------------------------------------- /Chapter08/P173_ClosedElectricPanelHierarchy/src/main/java/modern/circuit/resistor/MetalFilmResistor.java: -------------------------------------------------------------------------------- 1 | package modern.circuit.resistor; 2 | 3 | public final class MetalFilmResistor extends MetalResistor {} 4 | -------------------------------------------------------------------------------- /Chapter08/P173_ClosedElectricPanelHierarchy/src/main/java/modern/circuit/resistor/MetalOxideResistor.java: -------------------------------------------------------------------------------- 1 | package modern.circuit.resistor; 2 | 3 | public final class MetalOxideResistor extends MetalResistor {} 4 | -------------------------------------------------------------------------------- /Chapter08/P173_ClosedElectricPanelHierarchy/src/main/java/modern/circuit/resistor/MetalResistor.java: -------------------------------------------------------------------------------- 1 | package modern.circuit.resistor; 2 | 3 | public class MetalResistor extends Resistor {} 4 | -------------------------------------------------------------------------------- /Chapter08/P173_ClosedElectricPanelHierarchy/src/main/java/modern/circuit/transistor/BipolarTransistor.java: -------------------------------------------------------------------------------- 1 | package modern.circuit.transistor; 2 | 3 | public final class BipolarTransistor extends Transistor {} 4 | -------------------------------------------------------------------------------- /Chapter08/P173_ClosedElectricPanelHierarchy/src/main/java/modern/circuit/transistor/FieldEffectTransistor.java: -------------------------------------------------------------------------------- 1 | package modern.circuit.transistor; 2 | 3 | public final class FieldEffectTransistor extends Transistor {} 4 | -------------------------------------------------------------------------------- /Chapter08/P174_SealedHierarchySameSourceFile/README.md: -------------------------------------------------------------------------------- 1 | # Introducing JDK 17 Sealed Classes: 2 | Provide a brief introduction to JDK 17 Sealed Classes. Exemplify how to write closed hierarchies in a single source file via Sealed Classes. -------------------------------------------------------------------------------- /Chapter08/P174_SealedHierarchySameSourceFile/src/main/java/modern/challenge/Main.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public class Main { 4 | 5 | public static void main(String[] args) {} 6 | } -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparatePackages/README.md: -------------------------------------------------------------------------------- 1 | Introducing the permits clause: 2 | Explain and exemplify the role of the permits clause in Sealed Classes. Exemplify Sealed Classes in different source files (same package) and in different packages. -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparatePackages/src/main/java/com/refinery/gaseousfuel/Chloromethane.java: -------------------------------------------------------------------------------- 1 | package com.refinery.gaseousfuel; 2 | 3 | public final class Chloromethane extends Methane {} -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparatePackages/src/main/java/com/refinery/gaseousfuel/Dichloromethane.java: -------------------------------------------------------------------------------- 1 | package com.refinery.gaseousfuel; 2 | 3 | public sealed class Dichloromethane extends Methane permits Trichloromethane {} -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparatePackages/src/main/java/com/refinery/gaseousfuel/Hydrogen.java: -------------------------------------------------------------------------------- 1 | package com.refinery.gaseousfuel; 2 | 3 | public final class Hydrogen implements NaturalGas {} -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparatePackages/src/main/java/com/refinery/gaseousfuel/Methane.java: -------------------------------------------------------------------------------- 1 | package com.refinery.gaseousfuel; 2 | 3 | public sealed class Methane implements NaturalGas permits Chloromethane, Dichloromethane {} -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparatePackages/src/main/java/com/refinery/gaseousfuel/Propane.java: -------------------------------------------------------------------------------- 1 | package com.refinery.gaseousfuel; 2 | 3 | import com.rafinery.fuel.type.GaseousFuel; 4 | 5 | public final class Propane implements GaseousFuel {} -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparatePackages/src/main/java/com/refinery/gaseousfuel/Trichloromethane.java: -------------------------------------------------------------------------------- 1 | package com.refinery.gaseousfuel; 2 | 3 | public final class Trichloromethane extends Dichloromethane {} -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparatePackages/src/main/java/com/refinery/liquidfuel/Diesel.java: -------------------------------------------------------------------------------- 1 | package com.refinery.liquidfuel; 2 | 3 | public final class Diesel extends Petroleum {} 4 | -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparatePackages/src/main/java/com/refinery/liquidfuel/Ethanol.java: -------------------------------------------------------------------------------- 1 | package com.refinery.liquidfuel; 2 | 3 | public final class Ethanol extends Petroleum {} -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparatePackages/src/main/java/com/refinery/liquidfuel/Gasoline.java: -------------------------------------------------------------------------------- 1 | package com.refinery.liquidfuel; 2 | 3 | public final class Gasoline extends Petroleum {} 4 | -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparatePackages/src/main/java/com/refinery/solidfuel/Charcoal.java: -------------------------------------------------------------------------------- 1 | package com.refinery.solidfuel; 2 | 3 | import com.rafinery.fuel.type.SolidFuel; 4 | 5 | public final class Charcoal implements SolidFuel {} 6 | -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparatePackages/src/main/java/com/refinery/solidfuel/Coke.java: -------------------------------------------------------------------------------- 1 | package com.refinery.solidfuel; 2 | 3 | import com.rafinery.fuel.type.SolidFuel; 4 | 5 | public final class Coke implements SolidFuel {} 6 | -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparatePackages/src/main/java/modern/challenge/Main.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public class Main { 4 | 5 | public static void main(String[] args) {} 6 | } -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparatePackages/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module P175_SealedHierarchySeparatePackages {} -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparateSources/README.md: -------------------------------------------------------------------------------- 1 | Introducing the permits clause: 2 | Explain and exemplify the role of the permits clause in Sealed Classes. Exemplify Sealed Classes in different source files (same package) and in different packages. -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparateSources/src/main/java/com/refinery/fuel/Charcoal.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public final class Charcoal implements SolidFuel {} 4 | -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparateSources/src/main/java/com/refinery/fuel/Chloromethane.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public final class Chloromethane extends Methane {} -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparateSources/src/main/java/com/refinery/fuel/Coke.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public final class Coke implements SolidFuel {} 4 | -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparateSources/src/main/java/com/refinery/fuel/Dichloromethane.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public sealed class Dichloromethane extends Methane permits Trichloromethane {} -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparateSources/src/main/java/com/refinery/fuel/Diesel.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public final class Diesel extends Petroleum {} 4 | -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparateSources/src/main/java/com/refinery/fuel/Ethanol.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public final class Ethanol extends Petroleum {} -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparateSources/src/main/java/com/refinery/fuel/Fuel.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public sealed interface Fuel permits SolidFuel, LiquidFuel, GaseousFuel {} -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparateSources/src/main/java/com/refinery/fuel/GaseousFuel.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public sealed interface GaseousFuel extends Fuel permits NaturalGas, Propane {} 4 | -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparateSources/src/main/java/com/refinery/fuel/Gasoline.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public final class Gasoline extends Petroleum {} 4 | -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparateSources/src/main/java/com/refinery/fuel/Hydrogen.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public final class Hydrogen implements NaturalGas {} -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparateSources/src/main/java/com/refinery/fuel/LiquidFuel.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public sealed interface LiquidFuel extends Fuel permits Petroleum {} 4 | -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparateSources/src/main/java/com/refinery/fuel/Methane.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public sealed class Methane implements NaturalGas permits Chloromethane, Dichloromethane {} -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparateSources/src/main/java/com/refinery/fuel/NaturalGas.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public sealed interface NaturalGas extends GaseousFuel permits Hydrogen, Methane {} 4 | -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparateSources/src/main/java/com/refinery/fuel/Petroleum.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public sealed class Petroleum implements LiquidFuel permits Diesel, Gasoline, Ethanol {} -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparateSources/src/main/java/com/refinery/fuel/Propane.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public final class Propane implements GaseousFuel {} -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparateSources/src/main/java/com/refinery/fuel/SolidFuel.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public sealed interface SolidFuel extends Fuel permits Coke, Charcoal {} -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparateSources/src/main/java/com/refinery/fuel/Trichloromethane.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public final class Trichloromethane extends Dichloromethane {} -------------------------------------------------------------------------------- /Chapter08/P175_SealedHierarchySeparateSources/src/main/java/modern/challenge/Main.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public class Main { 4 | 5 | public static void main(String[] args) {} 6 | } -------------------------------------------------------------------------------- /Chapter08/P176_SealedElectricPanelHierarchy/README.md: -------------------------------------------------------------------------------- 1 | # Closing the electrical panel after JDK 17: 2 | Use Sealed Classes to completely close the electrical panel hierarchy developed in Problems 172 and 173. -------------------------------------------------------------------------------- /Chapter08/P176_SealedElectricPanelHierarchy/src/main/java/modern/circuit/capacitor/CeramicCapacitor.java: -------------------------------------------------------------------------------- 1 | package modern.circuit.capacitor; 2 | 3 | public final class CeramicCapacitor extends Capacitor {} 4 | -------------------------------------------------------------------------------- /Chapter08/P176_SealedElectricPanelHierarchy/src/main/java/modern/circuit/capacitor/ElectrolyticCapacitor.java: -------------------------------------------------------------------------------- 1 | package modern.circuit.capacitor; 2 | 3 | public final class ElectrolyticCapacitor extends Capacitor {} -------------------------------------------------------------------------------- /Chapter08/P176_SealedElectricPanelHierarchy/src/main/java/modern/circuit/resistor/CarbonResistor.java: -------------------------------------------------------------------------------- 1 | package modern.circuit.resistor; 2 | 3 | public final class CarbonResistor extends Resistor {} 4 | -------------------------------------------------------------------------------- /Chapter08/P176_SealedElectricPanelHierarchy/src/main/java/modern/circuit/resistor/MetalFilmResistor.java: -------------------------------------------------------------------------------- 1 | package modern.circuit.resistor; 2 | 3 | public final class MetalFilmResistor extends MetalResistor {} 4 | -------------------------------------------------------------------------------- /Chapter08/P176_SealedElectricPanelHierarchy/src/main/java/modern/circuit/resistor/MetalOxideResistor.java: -------------------------------------------------------------------------------- 1 | package modern.circuit.resistor; 2 | 3 | public final class MetalOxideResistor extends MetalResistor {} 4 | -------------------------------------------------------------------------------- /Chapter08/P176_SealedElectricPanelHierarchy/src/main/java/modern/circuit/resistor/MetalResistor.java: -------------------------------------------------------------------------------- 1 | package modern.circuit.resistor; 2 | 3 | public sealed class MetalResistor extends Resistor 4 | permits MetalFilmResistor, MetalOxideResistor {} 5 | -------------------------------------------------------------------------------- /Chapter08/P176_SealedElectricPanelHierarchy/src/main/java/modern/circuit/transistor/BipolarTransistor.java: -------------------------------------------------------------------------------- 1 | package modern.circuit.transistor; 2 | 3 | public final class BipolarTransistor extends Transistor {} 4 | -------------------------------------------------------------------------------- /Chapter08/P176_SealedElectricPanelHierarchy/src/main/java/modern/circuit/transistor/FieldEffectTransistor.java: -------------------------------------------------------------------------------- 1 | package modern.circuit.transistor; 2 | 3 | public final class FieldEffectTransistor extends Transistor {} 4 | -------------------------------------------------------------------------------- /Chapter08/P176_SealedElectricPanelHierarchy/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module P176_SealedElectricPanelHierarchy { 2 | exports modern.circuit.panel; 3 | } 4 | -------------------------------------------------------------------------------- /Chapter08/P177_SealedFuelHierarchyWithRecords/README.md: -------------------------------------------------------------------------------- 1 | # Combining sealed classes and records: 2 | Exemplify the usage of Java Records in combination with Sealed Classes. -------------------------------------------------------------------------------- /Chapter08/P177_SealedFuelHierarchyWithRecords/src/main/java/com/refinery/fuel/Charcoal.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public record Charcoal() implements SolidFuel {} 4 | -------------------------------------------------------------------------------- /Chapter08/P177_SealedFuelHierarchyWithRecords/src/main/java/com/refinery/fuel/Chloromethane.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public final class Chloromethane extends Methane {} -------------------------------------------------------------------------------- /Chapter08/P177_SealedFuelHierarchyWithRecords/src/main/java/com/refinery/fuel/Coke.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public record Coke() implements SolidFuel {} 4 | -------------------------------------------------------------------------------- /Chapter08/P177_SealedFuelHierarchyWithRecords/src/main/java/com/refinery/fuel/Dichloromethane.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public sealed class Dichloromethane extends Methane permits Trichloromethane {} -------------------------------------------------------------------------------- /Chapter08/P177_SealedFuelHierarchyWithRecords/src/main/java/com/refinery/fuel/Diesel.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public final class Diesel extends Petroleum {} 4 | -------------------------------------------------------------------------------- /Chapter08/P177_SealedFuelHierarchyWithRecords/src/main/java/com/refinery/fuel/Ethanol.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public final class Ethanol extends Petroleum {} -------------------------------------------------------------------------------- /Chapter08/P177_SealedFuelHierarchyWithRecords/src/main/java/com/refinery/fuel/Fuel.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public sealed interface Fuel permits SolidFuel, LiquidFuel, GaseousFuel {} -------------------------------------------------------------------------------- /Chapter08/P177_SealedFuelHierarchyWithRecords/src/main/java/com/refinery/fuel/GaseousFuel.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public sealed interface GaseousFuel extends Fuel permits NaturalGas, Propane {} 4 | -------------------------------------------------------------------------------- /Chapter08/P177_SealedFuelHierarchyWithRecords/src/main/java/com/refinery/fuel/Gasoline.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public final class Gasoline extends Petroleum {} 4 | -------------------------------------------------------------------------------- /Chapter08/P177_SealedFuelHierarchyWithRecords/src/main/java/com/refinery/fuel/Hydrogen.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public record Hydrogen() implements NaturalGas {} -------------------------------------------------------------------------------- /Chapter08/P177_SealedFuelHierarchyWithRecords/src/main/java/com/refinery/fuel/LiquidFuel.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public sealed interface LiquidFuel extends Fuel permits Petroleum {} 4 | -------------------------------------------------------------------------------- /Chapter08/P177_SealedFuelHierarchyWithRecords/src/main/java/com/refinery/fuel/Methane.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public sealed class Methane implements NaturalGas permits Chloromethane, Dichloromethane {} -------------------------------------------------------------------------------- /Chapter08/P177_SealedFuelHierarchyWithRecords/src/main/java/com/refinery/fuel/NaturalGas.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public sealed interface NaturalGas extends GaseousFuel permits Hydrogen, Methane {} 4 | -------------------------------------------------------------------------------- /Chapter08/P177_SealedFuelHierarchyWithRecords/src/main/java/com/refinery/fuel/Petroleum.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public sealed class Petroleum implements LiquidFuel permits Diesel, Gasoline, Ethanol {} -------------------------------------------------------------------------------- /Chapter08/P177_SealedFuelHierarchyWithRecords/src/main/java/com/refinery/fuel/Propane.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public record Propane() implements GaseousFuel {} -------------------------------------------------------------------------------- /Chapter08/P177_SealedFuelHierarchyWithRecords/src/main/java/com/refinery/fuel/SolidFuel.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public sealed interface SolidFuel extends Fuel permits Coke, Charcoal {} -------------------------------------------------------------------------------- /Chapter08/P177_SealedFuelHierarchyWithRecords/src/main/java/com/refinery/fuel/Trichloromethane.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public final class Trichloromethane extends Dichloromethane {} -------------------------------------------------------------------------------- /Chapter08/P177_SealedFuelHierarchyWithRecords/src/main/java/modern/challenge/Main.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public class Main { 4 | 5 | public static void main(String[] args) {} 6 | } -------------------------------------------------------------------------------- /Chapter08/P178_SealedClassesCastConvInstanceof1/README.md: -------------------------------------------------------------------------------- 1 | # Hooking sealed classes and instanceof: 2 | Write an application that highlights how Sealed Classes help the compiler to better handle the instanceof operator. -------------------------------------------------------------------------------- /Chapter08/P178_SealedClassesCastConvInstanceof1/src/main/java/modern/challenge/Quadrilateral.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public interface Quadrilateral {} 4 | -------------------------------------------------------------------------------- /Chapter08/P178_SealedClassesCastConvInstanceof1/src/main/java/modern/challenge/Rectangle.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public class Rectangle extends Triangle implements Quadrilateral {} -------------------------------------------------------------------------------- /Chapter08/P178_SealedClassesCastConvInstanceof1/src/main/java/modern/challenge/Triangle.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public class Triangle {} -------------------------------------------------------------------------------- /Chapter08/P178_SealedClassesCastConvInstanceof2/README.md: -------------------------------------------------------------------------------- 1 | # Hooking sealed classes and instanceof: 2 | Write an application that highlights how Sealed Classes help the compiler to better handle the instanceof operator. -------------------------------------------------------------------------------- /Chapter08/P178_SealedClassesCastConvInstanceof2/src/main/java/modern/challenge/Quadrilateral.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public interface Quadrilateral {} 4 | -------------------------------------------------------------------------------- /Chapter08/P178_SealedClassesCastConvInstanceof2/src/main/java/modern/challenge/Triangle.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public final class Triangle {} -------------------------------------------------------------------------------- /Chapter08/P178_SealedClassesCastConvInstanceof3/README.md: -------------------------------------------------------------------------------- 1 | # Hooking sealed classes and instanceof: 2 | Write an application that highlights how Sealed Classes help the compiler to better handle the instanceof operator. -------------------------------------------------------------------------------- /Chapter08/P178_SealedClassesCastConvInstanceof3/src/main/java/modern/challenge/Quadrilateral.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public sealed interface Quadrilateral permits Rectangle {} 4 | -------------------------------------------------------------------------------- /Chapter08/P178_SealedClassesCastConvInstanceof3/src/main/java/modern/challenge/Triangle.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public class Triangle {} -------------------------------------------------------------------------------- /Chapter08/P179_SealedClassesAndSwitch/README.md: -------------------------------------------------------------------------------- 1 | # Hooking sealed classes in switch: 2 | Write an application that exemplifies how Sealed Classes help the compiler to sustain exhaustive switch expressions/statements. -------------------------------------------------------------------------------- /Chapter08/P179_SealedClassesAndSwitch/src/main/java/modern/challenge/TextConverter.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public sealed abstract class TextConverter permits Utf8, Utf16, Utf32 {} 4 | -------------------------------------------------------------------------------- /Chapter08/P179_SealedClassesAndSwitch/src/main/java/modern/challenge/Utf16.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | non-sealed public class Utf16 extends TextConverter {} 4 | -------------------------------------------------------------------------------- /Chapter08/P179_SealedClassesAndSwitch/src/main/java/modern/challenge/Utf16be.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public final class Utf16be extends Utf16 {} 4 | -------------------------------------------------------------------------------- /Chapter08/P179_SealedClassesAndSwitch/src/main/java/modern/challenge/Utf16le.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public final class Utf16le extends Utf16 {} -------------------------------------------------------------------------------- /Chapter08/P179_SealedClassesAndSwitch/src/main/java/modern/challenge/Utf32.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | final public class Utf32 extends TextConverter {} 4 | -------------------------------------------------------------------------------- /Chapter08/P179_SealedClassesAndSwitch/src/main/java/modern/challenge/Utf8.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | final public class Utf8 extends TextConverter {} 4 | -------------------------------------------------------------------------------- /Chapter08/P179_SealedClassesSwitchBinTree/README.md: -------------------------------------------------------------------------------- 1 | # Hooking sealed classes in switch: 2 | Write an application that exemplifies how Sealed Classes help the compiler to sustain exhaustive switch expressions/statements. -------------------------------------------------------------------------------- /Chapter08/P180_SealedClassesAndVisitorPattern1/src/main/java/modern/challenge/ElectricComponent.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public interface ElectricComponent { 4 | 5 | public String accept(ElectricComponentVisitor visitor); 6 | } 7 | -------------------------------------------------------------------------------- /Chapter08/P180_SealedClassesAndVisitorPattern2/src/main/java/modern/challenge/ElectricComponent.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public sealed interface ElectricComponent 4 | permits Capacitor, Transistor, Resistor, ElectricCircuit {} 5 | -------------------------------------------------------------------------------- /Chapter08/P181_SealedClassesAndReflection/README.md: -------------------------------------------------------------------------------- 1 | # Getting info about Sealed Classes (using reflection): 2 | Explain and exemplify how we can access Sealed Classes via Java reflection. -------------------------------------------------------------------------------- /Chapter08/P181_SealedClassesAndReflection/src/main/java/com/refinery/fuel/Charcoal.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public final class Charcoal implements SolidFuel {} 4 | -------------------------------------------------------------------------------- /Chapter08/P181_SealedClassesAndReflection/src/main/java/com/refinery/fuel/Chloromethane.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public final class Chloromethane extends Methane {} -------------------------------------------------------------------------------- /Chapter08/P181_SealedClassesAndReflection/src/main/java/com/refinery/fuel/Coke.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public final class Coke implements SolidFuel {} 4 | -------------------------------------------------------------------------------- /Chapter08/P181_SealedClassesAndReflection/src/main/java/com/refinery/fuel/Dichloromethane.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public sealed class Dichloromethane extends Methane permits Trichloromethane {} -------------------------------------------------------------------------------- /Chapter08/P181_SealedClassesAndReflection/src/main/java/com/refinery/fuel/Diesel.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public final class Diesel extends Petroleum {} 4 | -------------------------------------------------------------------------------- /Chapter08/P181_SealedClassesAndReflection/src/main/java/com/refinery/fuel/Ethanol.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public final class Ethanol extends Petroleum {} -------------------------------------------------------------------------------- /Chapter08/P181_SealedClassesAndReflection/src/main/java/com/refinery/fuel/Fuel.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public sealed interface Fuel permits SolidFuel, LiquidFuel, GaseousFuel {} -------------------------------------------------------------------------------- /Chapter08/P181_SealedClassesAndReflection/src/main/java/com/refinery/fuel/GaseousFuel.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public sealed interface GaseousFuel extends Fuel permits NaturalGas, Propane {} 4 | -------------------------------------------------------------------------------- /Chapter08/P181_SealedClassesAndReflection/src/main/java/com/refinery/fuel/Gasoline.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public final class Gasoline extends Petroleum {} 4 | -------------------------------------------------------------------------------- /Chapter08/P181_SealedClassesAndReflection/src/main/java/com/refinery/fuel/Hydrogen.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public final class Hydrogen implements NaturalGas {} -------------------------------------------------------------------------------- /Chapter08/P181_SealedClassesAndReflection/src/main/java/com/refinery/fuel/LiquidFuel.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public sealed interface LiquidFuel extends Fuel permits Petroleum {} 4 | -------------------------------------------------------------------------------- /Chapter08/P181_SealedClassesAndReflection/src/main/java/com/refinery/fuel/Methane.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public sealed class Methane implements NaturalGas permits Chloromethane, Dichloromethane {} -------------------------------------------------------------------------------- /Chapter08/P181_SealedClassesAndReflection/src/main/java/com/refinery/fuel/NaturalGas.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public sealed interface NaturalGas extends GaseousFuel permits Hydrogen, Methane {} 4 | -------------------------------------------------------------------------------- /Chapter08/P181_SealedClassesAndReflection/src/main/java/com/refinery/fuel/Petroleum.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public sealed class Petroleum implements LiquidFuel permits Diesel, Gasoline, Ethanol {} -------------------------------------------------------------------------------- /Chapter08/P181_SealedClassesAndReflection/src/main/java/com/refinery/fuel/Propane.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public final class Propane implements GaseousFuel {} -------------------------------------------------------------------------------- /Chapter08/P181_SealedClassesAndReflection/src/main/java/com/refinery/fuel/SolidFuel.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public sealed interface SolidFuel extends Fuel permits Coke, Charcoal {} -------------------------------------------------------------------------------- /Chapter08/P181_SealedClassesAndReflection/src/main/java/com/refinery/fuel/Trichloromethane.java: -------------------------------------------------------------------------------- 1 | package com.refinery.fuel; 2 | 3 | public final class Trichloromethane extends Dichloromethane {} -------------------------------------------------------------------------------- /Chapter08/P184_HiddenClasses/README.md: -------------------------------------------------------------------------------- 1 | # Creating a hidden class: 2 | Provide a regular example of creating and using a hidden class. -------------------------------------------------------------------------------- /Chapter08/P184_HiddenClasses/src/main/java/modern/challenge/Math.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public interface Math {} 4 | -------------------------------------------------------------------------------- /Chapter09/P185_MapMulti1/README.md: -------------------------------------------------------------------------------- 1 | # Working with mapMulti(): 2 | Explain and exemplify the JDK 16, mapMulti(). Provide a brief introduction, explain how it works in comparison with flatMap(), and point out when mapMulti() is a good fit. -------------------------------------------------------------------------------- /Chapter09/P185_MapMulti2/README.md: -------------------------------------------------------------------------------- 1 | # Working with mapMulti(): 2 | Explain and exemplify the JDK 16, mapMulti(). Provide a brief introduction, explain how it works in comparison with flatMap(), and point out when mapMulti() is a good fit. -------------------------------------------------------------------------------- /Chapter09/P187_LambdaVsMethodReference/README.md: -------------------------------------------------------------------------------- 1 | # Exemplifying method reference vs. lambda: 2 | Write a relevant snippet of code for highlighting the difference in behavior between a method reference and the equivalent lambda expression. -------------------------------------------------------------------------------- /Chapter09/P188_LambdaLaziness/README.md: -------------------------------------------------------------------------------- 1 | # Hooking lambda laziness via Supplier/Consumer: 2 | Write a Java program that highlights how Supplier/Consumer works. In this context, point out the lazy characteristic of lambdas. -------------------------------------------------------------------------------- /Chapter09/P189_LambdaLazinessDysfunctional/README.md: -------------------------------------------------------------------------------- 1 | # Refactoring code to add lambda laziness: 2 | Provide a simple example of refactoring a piece of imperative code via functional code. -------------------------------------------------------------------------------- /Chapter09/P189_LambdaLazinessFunctional/README.md: -------------------------------------------------------------------------------- 1 | # Refactoring code to add lambda laziness: 2 | Provide a simple example of refactoring a piece of imperative code via functional code. -------------------------------------------------------------------------------- /Chapter09/P189_LambdaLazinessFunctional/src/main/java/modern/challenge/FSupplier.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | import java.util.function.Supplier; 4 | 5 | @FunctionalInterface 6 | public interface FSupplier extends Supplier {} 7 | -------------------------------------------------------------------------------- /Chapter09/P189_LambdaLazinessImperative/README.md: -------------------------------------------------------------------------------- 1 | # Refactoring code to add lambda laziness: 2 | Provide a simple example of refactoring a piece of imperative code via functional code. -------------------------------------------------------------------------------- /Chapter09/P191_ApplyMultiplePredicates/README.md: -------------------------------------------------------------------------------- 1 | # Composing predicates in Stream’s filters: 2 | Write several examples that highlight the usage of composite predicates in filters. -------------------------------------------------------------------------------- /Chapter09/P192_FilterNestedCollection/README.md: -------------------------------------------------------------------------------- 1 | # Filtering nested collections with Streams: 2 | Imagine that you have two nested collections. Provide several stream pipeline examples for filtering data from the inner collection. -------------------------------------------------------------------------------- /Chapter09/P193_UsingBiPredicate/README.md: -------------------------------------------------------------------------------- 1 | # Using BiPredicate: 2 | Exemplify the usage of BiPredicate. -------------------------------------------------------------------------------- /Chapter09/P194_BuildCustomPredicate/README.md: -------------------------------------------------------------------------------- 1 | # Building a dynamic predicate for a custom model: 2 | Write an application capable of dynamically generating predicates (Predicate) based on some simple inputs. -------------------------------------------------------------------------------- /Chapter09/P196_LoggingPredicate/README.md: -------------------------------------------------------------------------------- 1 | # Logging in predicates: 2 | Write a custom solution that allows us to log failures in predicates. -------------------------------------------------------------------------------- /Chapter09/P197_ImplementingContainsAllAny1/README.md: -------------------------------------------------------------------------------- 1 | # Extending Stream with containsAll, containsAny: 2 | Provide a solution that extends the Java Stream API with two final operations named containsAll() and containsAny(). -------------------------------------------------------------------------------- /Chapter09/P197_ImplementingContainsAllAny2/README.md: -------------------------------------------------------------------------------- 1 | # Extending Stream with containsAll, containsAny: 2 | Provide a solution that extends the Java Stream API with two final operations named containsAll() and containsAny(). -------------------------------------------------------------------------------- /Chapter09/P198_ImplementingRemoveRetainAll1/README.md: -------------------------------------------------------------------------------- 1 | # Extending Stream with removeAll, retainAll: 2 | Provide a solution that extends the Java Stream API with two final operations named removeAll() and retainAll(). -------------------------------------------------------------------------------- /Chapter09/P198_ImplementingRemoveRetainAll2/README.md: -------------------------------------------------------------------------------- 1 | # Extending Stream with removeAll, retainAll: 2 | Provide a solution that extends the Java Stream API with two final operations named removeAll() and retainAll(). -------------------------------------------------------------------------------- /Chapter09/P199_StreamComparators/README.md: -------------------------------------------------------------------------------- 1 | # Introducing stream comparators: 2 | Provide a detailed covering (with examples) of using stream comparators. -------------------------------------------------------------------------------- /Chapter09/P200_CustomSortedComparator/README.md: -------------------------------------------------------------------------------- 1 | # Sorting a map: 2 | Write several snippets of code for highlighting different use cases for sorting a map. -------------------------------------------------------------------------------- /Chapter09/P201_FilteringMap/README.md: -------------------------------------------------------------------------------- 1 | # Filtering a map: 2 | Write several snippets of code for highlighting different use cases for filtering a map. -------------------------------------------------------------------------------- /Chapter09/P202_CustomCollectorOf/README.md: -------------------------------------------------------------------------------- 1 | # Creating a custom collector via Collector.of(): 2 | Write an arbitrarily chosen set of custom collectors via the Collector.of() API. -------------------------------------------------------------------------------- /Chapter09/P202_CustomCollectorOf/src/main/java/modern/challenge/Vehicle.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public interface Vehicle {} 4 | -------------------------------------------------------------------------------- /Chapter09/P203_StreamAndCheckedException/README.md: -------------------------------------------------------------------------------- 1 | # Throwing checked exceptions from lambdas: 2 | Provide a hack that allows us to throw checked exceptions from lambdas. -------------------------------------------------------------------------------- /Chapter09/P206_FunctionWith5Args/README.md: -------------------------------------------------------------------------------- 1 | # Implementing a Function that takes 5 (or any other arbitrary number) of arguments: 2 | Write and use a 5-argument functional interface that represents a specialization of java.util.function.Function. -------------------------------------------------------------------------------- /Chapter09/P206_FunctionWith5Args/src/main/java/modern/challenge/FiveFunction.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | @FunctionalInterface 4 | public interface FiveFunction { 5 | 6 | R apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5); 7 | } 8 | -------------------------------------------------------------------------------- /Chapter09/P207_ConsumerWith5Args/README.md: -------------------------------------------------------------------------------- 1 | # Implementing a Consumer that takes 5 (or any other arbitrary number) of arguments: 2 | Write and use a 5-argument functional interface that represents a specialization of java.util.function.Consumer. -------------------------------------------------------------------------------- /Chapter10/P210_UnstructuredConcurrencySample/README.md: -------------------------------------------------------------------------------- 1 | # Introducing structured concurrency: 2 | Write an example highlighting the main issues of "unstructured" concurrency. Moreover, provide an introduction to the structured concurrency paradigm. -------------------------------------------------------------------------------- /Chapter10/P210_UnstructuredConcurrencySample/src/main/java/modern/challenge/TestingTeam.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record TestingTeam(String... testers) {} 4 | -------------------------------------------------------------------------------- /Chapter10/P211_HowManyThreadsCreate/README.md: -------------------------------------------------------------------------------- 1 | # Introducing virtual threads: 2 | Explain and exemplify the main concepts of virtual threads. -------------------------------------------------------------------------------- /Chapter10/P211_IntroCheckVirtualThread/README.md: -------------------------------------------------------------------------------- 1 | # Introducing virtual threads: 2 | Explain and exemplify the main concepts of virtual threads. -------------------------------------------------------------------------------- /Chapter10/P211_IntroStartVirtualThread/README.md: -------------------------------------------------------------------------------- 1 | # Introducing virtual threads: 2 | Explain and exemplify the main concepts of virtual threads. -------------------------------------------------------------------------------- /Chapter10/P211_IntroStartVirtualThreadBuilder/README.md: -------------------------------------------------------------------------------- 1 | # Introducing virtual threads: 2 | Explain and exemplify the main concepts of virtual threads. -------------------------------------------------------------------------------- /Chapter10/P211_IntroUnstartedVirtualThread/README.md: -------------------------------------------------------------------------------- 1 | # Introducing virtual threads: 2 | Explain and exemplify the main concepts of virtual threads.ss -------------------------------------------------------------------------------- /Chapter10/P211_IntroVirtualThreadFactory/README.md: -------------------------------------------------------------------------------- 1 | # Introducing virtual threads: 2 | Explain and exemplify the main concepts of virtual threads. -------------------------------------------------------------------------------- /Chapter10/P212_IntroNewVirtualThreadPerTaskExecutor/README.md: -------------------------------------------------------------------------------- 1 | # Using the ExecutorService for virtual threads: 2 | Write several examples that highlight the task-per-thread model via ExecutorService and virtual threads. -------------------------------------------------------------------------------- /Chapter10/P213_VirtualThreadForkJoinPool/README.md: -------------------------------------------------------------------------------- 1 | # Explaining how virtual threads work: 2 | Provide comprehensive coverage of how virtual threads work internally. -------------------------------------------------------------------------------- /Chapter10/P214_VirtualThreadsAndSyncCode1/README.md: -------------------------------------------------------------------------------- 1 | # Hooking virtual threads and sync code: 2 | Explain and exemplify via a meaningful snippet of code how virtual threads and sync code work together. -------------------------------------------------------------------------------- /Chapter10/P214_VirtualThreadsAndSyncCode2/README.md: -------------------------------------------------------------------------------- 1 | # Hooking virtual threads and sync code: 2 | Explain and exemplify via a meaningful snippet of code how virtual threads and sync code work together. -------------------------------------------------------------------------------- /Chapter10/P215_ContextSwitching1/README.md: -------------------------------------------------------------------------------- 1 | # Exemplifying thread context switching: 2 | Write several examples that show how thread context switching works for virtual threads. -------------------------------------------------------------------------------- /Chapter10/P215_ContextSwitching2/README.md: -------------------------------------------------------------------------------- 1 | # Exemplifying thread context switching: 2 | Write several examples that show how thread context switching works for virtual threads. -------------------------------------------------------------------------------- /Chapter10/P215_ContextSwitching3/README.md: -------------------------------------------------------------------------------- 1 | # Exemplifying thread context switching: 2 | Write several examples that show how thread context switching works for virtual threads. -------------------------------------------------------------------------------- /Chapter10/P216_NewVirtualThreadPerTaskExecutorInvokeAllAny/README.md: -------------------------------------------------------------------------------- 1 | # Introducing the ExecutorService invoke all/any for virtual threads – part 1: 2 | Provide a brief introduction of ExecutorService invoke all/any for virtual threads. -------------------------------------------------------------------------------- /Chapter10/P217_InvokeAllOnSuccess/README.md: -------------------------------------------------------------------------------- 1 | # Introducing the ExecutorService invoke all/any for virtual threads – part 2: 2 | Re-write the example of "unstructured" concurrency from Problem 210 via ExecutorService invoke all/any for virtual threads. -------------------------------------------------------------------------------- /Chapter10/P217_InvokeAllOnSuccess/src/main/java/modern/challenge/TestingTeam.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record TestingTeam(String... testers) {} 4 | -------------------------------------------------------------------------------- /Chapter10/P217_InvokeAnyOnSuccess/README.md: -------------------------------------------------------------------------------- 1 | # Introducing the ExecutorService invoke all/any for virtual threads – part 2: 2 | Re-write the example of "unstructured" concurrency from Problem 210 via ExecutorService invoke all/any for virtual threads. -------------------------------------------------------------------------------- /Chapter10/P217_InvokeAnyOnSuccess/src/main/java/modern/challenge/TestingTeam.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record TestingTeam(String... testers) {} 4 | -------------------------------------------------------------------------------- /Chapter10/P218_HookingTaskState/README.md: -------------------------------------------------------------------------------- 1 | # Hooking task state: 2 | Explain and exemplify the new Future#state() API. -------------------------------------------------------------------------------- /Chapter10/P218_HookingTaskState/src/main/java/modern/challenge/TestingTeam.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record TestingTeam(String... testers) {} 4 | 5 | -------------------------------------------------------------------------------- /Chapter10/P219_NewVirtualThreadPerTaskExecutorStream1/README.md: -------------------------------------------------------------------------------- 1 | # Combining newVirtualThreadPerTaskExecutor() and streams: 2 | Write several examples that introduce how Java stream pipelines can be combined with the newVirtualThreadPerTaskExecutor() executor. -------------------------------------------------------------------------------- /Chapter10/P219_NewVirtualThreadPerTaskExecutorStream2/README.md: -------------------------------------------------------------------------------- 1 | # Combining newVirtualThreadPerTaskExecutor() and streams: 2 | Write several examples that introduce how Java stream pipelines can be combined with the newVirtualThreadPerTaskExecutor() executor. -------------------------------------------------------------------------------- /Chapter10/P220_IntroStructuredTaskScope/README.md: -------------------------------------------------------------------------------- 1 | # Introducing scope object (StructuredTaskScope): 2 | Provide a brief introduction of structured concurrency via the StructuredTaskScope API. -------------------------------------------------------------------------------- /Chapter10/P220_IntroStructuredTaskScope/src/main/java/modern/challenge/TestingTeam.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record TestingTeam(String... testers) {} 4 | -------------------------------------------------------------------------------- /Chapter10/P221_IntroStructuredTaskScopeOnSuccess1/README.md: -------------------------------------------------------------------------------- 1 | # Introducing ShutdownOnSuccess: 2 | Exemplify the ShutdownOnSuccess flavor of StructuredTaskScope. -------------------------------------------------------------------------------- /Chapter10/P221_IntroStructuredTaskScopeOnSuccess1/src/main/java/modern/challenge/TestingTeam.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record TestingTeam(String... testers) {} 4 | -------------------------------------------------------------------------------- /Chapter10/P221_IntroStructuredTaskScopeOnSuccess2/README.md: -------------------------------------------------------------------------------- 1 | # Introducing ShutdownOnSuccess: 2 | Exemplify the ShutdownOnSuccess flavor of StructuredTaskScope. -------------------------------------------------------------------------------- /Chapter10/P221_IntroStructuredTaskScopeOnSuccess2/src/main/java/modern/challenge/TestingTeam.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record TestingTeam(String... testers) {} 4 | -------------------------------------------------------------------------------- /Chapter10/P222_IntroStructuredTaskScopeOnFailure1/README.md: -------------------------------------------------------------------------------- 1 | # Introducing ShutdownOnFailure: 2 | Exemplify the ShutdownOnFailure flavor of StructuredTaskScope. -------------------------------------------------------------------------------- /Chapter10/P222_IntroStructuredTaskScopeOnFailure1/src/main/java/modern/challenge/TestingTeam.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record TestingTeam(String... testers) {} 4 | -------------------------------------------------------------------------------- /Chapter10/P222_IntroStructuredTaskScopeOnFailure2/README.md: -------------------------------------------------------------------------------- 1 | # Introducing ShutdownOnFailure: 2 | Exemplify the ShutdownOnFailure flavor of StructuredTaskScope. -------------------------------------------------------------------------------- /Chapter10/P222_IntroStructuredTaskScopeOnFailure2/src/main/java/modern/challenge/TestingTeam.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record TestingTeam(String... testers) {} 4 | -------------------------------------------------------------------------------- /Chapter10/P223_StructuredTaskScopeStream1/README.md: -------------------------------------------------------------------------------- 1 | # Combining StructuredTaskScope and streams: 2 | Write several examples that introduce how Java stream pipelines can be combined with StructuredTaskScope. -------------------------------------------------------------------------------- /Chapter10/P223_StructuredTaskScopeStream1/src/main/java/modern/challenge/TestingTeam.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record TestingTeam(String... testers) {} 4 | -------------------------------------------------------------------------------- /Chapter10/P223_StructuredTaskScopeStream2/README.md: -------------------------------------------------------------------------------- 1 | # Combining StructuredTaskScope and streams: 2 | Write several examples that introduce how Java stream pipelines can be combined with StructuredTaskScope. -------------------------------------------------------------------------------- /Chapter10/P223_StructuredTaskScopeStream2/src/main/java/modern/challenge/TestingTeam.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record TestingTeam(String... testers) {} 4 | -------------------------------------------------------------------------------- /Chapter10/P224_MonitoringVirtualThreadsJfr1/README.md: -------------------------------------------------------------------------------- 1 | # Observing and monitoring virtual threads: 2 | Exemplify how we can use JFR (Java Flight Recorder), JMX (Java Management Extensions), and any other tool that you like, for observing and monitoring virtual threads. -------------------------------------------------------------------------------- /Chapter10/P224_MonitoringVirtualThreadsJfr1/recording.jfr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter10/P224_MonitoringVirtualThreadsJfr1/recording.jfr -------------------------------------------------------------------------------- /Chapter10/P224_MonitoringVirtualThreadsJfr1/src/main/java/modern/challenge/TestingTeam.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record TestingTeam(String... testers) {} 4 | -------------------------------------------------------------------------------- /Chapter10/P224_MonitoringVirtualThreadsJfr2/README.md: -------------------------------------------------------------------------------- 1 | # Observing and monitoring virtual threads: 2 | Exemplify how we can use JFR (Java Flight Recorder), JMX (Java Management Extensions), and any other tool that you like, for observing and monitoring virtual threads. -------------------------------------------------------------------------------- /Chapter10/P224_MonitoringVirtualThreadsJfr2/recording.jfr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter10/P224_MonitoringVirtualThreadsJfr2/recording.jfr -------------------------------------------------------------------------------- /Chapter10/P224_MonitoringVirtualThreadsJfr2/src/main/java/modern/challenge/TestingTeam.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record TestingTeam(String... testers) {} 4 | -------------------------------------------------------------------------------- /Chapter10/P224_MonitoringVirtualThreadsJmx1/README.md: -------------------------------------------------------------------------------- 1 | # Observing and monitoring virtual threads: 2 | Exemplify how we can use JFR (Java Flight Recorder), JMX (Java Management Extensions), and any other tool that you like, for observing and monitoring virtual threads. -------------------------------------------------------------------------------- /Chapter10/P224_MonitoringVirtualThreadsJmx2/README.md: -------------------------------------------------------------------------------- 1 | # Observing and monitoring virtual threads: 2 | Exemplify how we can use JFR (Java Flight Recorder), JMX (Java Management Extensions), and any other tool that you like, for observing and monitoring virtual threads. -------------------------------------------------------------------------------- /Chapter10/P224_MonitoringVirtualThreadsJmx3/README.md: -------------------------------------------------------------------------------- 1 | # Observing and monitoring virtual threads: 2 | Exemplify how we can use JFR (Java Flight Recorder), JMX (Java Management Extensions), and any other tool that you like, for observing and monitoring virtual threads. -------------------------------------------------------------------------------- /Chapter10/P224_MonitoringVirtualThreadsJmx4/README.md: -------------------------------------------------------------------------------- 1 | # Observing and monitoring virtual threads: 2 | Exemplify how we can use JFR (Java Flight Recorder), JMX (Java Management Extensions), and any other tool that you like, for observing and monitoring virtual threads. -------------------------------------------------------------------------------- /Chapter11/P225_SimpleVirtualThreadContinuations/README.md: -------------------------------------------------------------------------------- 1 | # Tackling continuations: 2 | Provide a detailed explanation of what continuations are and how they work in the context of virtual threads. -------------------------------------------------------------------------------- /Chapter11/P227_ExtendStructuredTaskScope/README.md: -------------------------------------------------------------------------------- 1 | # Extending StructuredTaskScope: 2 | Explain and exemplify the steps for extending the StructuredTaskScope. Explain why we cannot extend ShutdownOnSuccess and ShutdownOnFailure. -------------------------------------------------------------------------------- /Chapter11/P228_AssembleStructuredTaskScope/README.md: -------------------------------------------------------------------------------- 1 | # Assembling StructuredTaskScope: 2 | Write a Java application that assembles (nest) multiple StructuredTaskScope. -------------------------------------------------------------------------------- /Chapter11/P228_AssembleStructuredTaskScope/src/main/java/modern/challenge/Travel.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public sealed interface Travel 4 | permits RidesharingOffer, PublicTransportOffer {} 5 | -------------------------------------------------------------------------------- /Chapter11/P228_AssembleStructuredTaskScope/src/main/java/modern/challenge/TravelOffer.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record TravelOffer(RidesharingOffer ridesharingOffer, PublicTransportOffer publicTransportOffer) {} 4 | -------------------------------------------------------------------------------- /Chapter11/P229_AssembleStructuredTaskScopeTimeout/README.md: -------------------------------------------------------------------------------- 1 | # Assembling StructuredTaskScope with timeout: 2 | Modify the application developed in Problem 228 to add a timeout/deadline to the forked tasks. -------------------------------------------------------------------------------- /Chapter11/P229_AssembleStructuredTaskScopeTimeout/src/main/java/modern/challenge/Travel.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public sealed interface Travel 4 | permits RidesharingOffer, PublicTransportOffer {} 5 | -------------------------------------------------------------------------------- /Chapter11/P229_AssembleStructuredTaskScopeTimeout/src/main/java/modern/challenge/TravelOffer.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record TravelOffer(RidesharingOffer ridesharingOffer, PublicTransportOffer publicTransportOffer) {} 4 | -------------------------------------------------------------------------------- /Chapter11/P230_VirtualThreadAndThreadLocal/README.md: -------------------------------------------------------------------------------- 1 | # Hooking ThreadLocal and virtual threads: 2 | Exemplify the use of ThreadLocal and virtual threads. -------------------------------------------------------------------------------- /Chapter11/P231_IntroScopedValues1/README.md: -------------------------------------------------------------------------------- 1 | # Hooking ScopedValue and virtual threads: 2 | Provide a comprehensive introduction with examples of the ScopedValue API. -------------------------------------------------------------------------------- /Chapter11/P231_IntroScopedValues2/README.md: -------------------------------------------------------------------------------- 1 | # Hooking ScopedValue and virtual threads: 2 | Provide a comprehensive introduction with examples of the ScopedValue API. -------------------------------------------------------------------------------- /Chapter11/P231_IntroScopedValues3/README.md: -------------------------------------------------------------------------------- 1 | # Hooking ScopedValue and virtual threads: 2 | Provide a comprehensive introduction with examples of the ScopedValue API. -------------------------------------------------------------------------------- /Chapter11/P231_IntroScopedValues4/README.md: -------------------------------------------------------------------------------- 1 | # Hooking ScopedValue and virtual threads: 2 | Provide a comprehensive introduction with examples of the ScopedValue API. -------------------------------------------------------------------------------- /Chapter11/P232_ScopedValueAndExecutorService/README.md: -------------------------------------------------------------------------------- 1 | # Using ScopedValue and executor services: 2 | Write a snippet of code that emphasizes the usage of ScopedValue API in the context of executor services. -------------------------------------------------------------------------------- /Chapter11/P233_ChainRebindScopedValues/README.md: -------------------------------------------------------------------------------- 1 | # Chaining and rebinding scoped values: 2 | Provide a few snippets of code that show how scoped values can be chained and rebound. -------------------------------------------------------------------------------- /Chapter11/P234_ScopedValueAndStructuredTaskScope/src/main/java/modern/challenge/Travel.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public sealed interface Travel 4 | permits RidesharingOffer, PublicTransportOffer {} 5 | -------------------------------------------------------------------------------- /Chapter11/P234_ScopedValueAndStructuredTaskScope/src/main/java/modern/challenge/TravelOffer.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record TravelOffer(RidesharingOffer ridesharingOffer, PublicTransportOffer publicTransportOffer) {} 4 | -------------------------------------------------------------------------------- /Chapter11/P235_SemaphoreVsExecutor/README.md: -------------------------------------------------------------------------------- 1 | # Using Semaphore instead of Executor: 2 | In the context of virtual threads, explain the benefits and exemplify the usage of Semaphore instead of an executor (for instance, instead of newFixedThreadPool()). -------------------------------------------------------------------------------- /Chapter11/P236_AvoidPinningViaLocking/README.md: -------------------------------------------------------------------------------- 1 | # Avoiding pinning via locking: 2 | Explain and exemplify how we can avoid pinned virtual threads by refactoring synchronized code via ReentrantLock. -------------------------------------------------------------------------------- /Chapter11/P238_FixedVirtualThreadProducerConsumer/README.md: -------------------------------------------------------------------------------- 1 | # Solving the producer-consumer problem via virtual threads (fixed via Semaphore): 2 | Adapt the application developed in Problem 237 to use Semaphore instead of executor services. -------------------------------------------------------------------------------- /Chapter11/P241_CompletableFutureAndVirtualThreads/README.md: -------------------------------------------------------------------------------- 1 | # Hooking CompletableFuture and virtual threads: 2 | Exemplify the usage of CompletableFuture and virtual threads to solve asynchronous tasks. -------------------------------------------------------------------------------- /Chapter11/P241_CompletableFutureAndVirtualThreads/src/main/java/modern/challenge/TestingTeam.java: -------------------------------------------------------------------------------- 1 | package modern.challenge; 2 | 3 | public record TestingTeam(String... testers) {} 4 | -------------------------------------------------------------------------------- /Chapter12/P255_LoggingGC/README.md: -------------------------------------------------------------------------------- 1 | # Logging Garbage Collector: 2 | Provide the steps needed to log the Garbage Collector activity. Moreover, highlight some tools capable to analyze and plot the logged data. -------------------------------------------------------------------------------- /Chapter12/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter12/README.md -------------------------------------------------------------------------------- /Chapter13/P261_BlockingEchoClient/README.md: -------------------------------------------------------------------------------- 1 | # Writing a blocking TCP server/client application: 2 | Provide a detailed example (theory and code) of a blocking TCP server/client application. -------------------------------------------------------------------------------- /Chapter13/P261_BlockingEchoServer/README.md: -------------------------------------------------------------------------------- 1 | # Writing a blocking TCP server/client application: 2 | Provide a detailed example (theory and code) of a blocking TCP server/client application. -------------------------------------------------------------------------------- /Chapter13/P262_NonBlockingEchoClient/README.md: -------------------------------------------------------------------------------- 1 | # Writing a non-blocking TCP server/client application: 2 | Provide a detailed example (theory and code) of a non-blocking TCP server/client application. -------------------------------------------------------------------------------- /Chapter13/P262_NonBlockingEchoServer/README.md: -------------------------------------------------------------------------------- 1 | # Writing a non-blocking TCP server/client application: 2 | Provide a detailed example (theory and code) of a non-blocking TCP server/client application. -------------------------------------------------------------------------------- /Chapter13/P263_BlockingEchoServer/README.md: -------------------------------------------------------------------------------- 1 | # Writing UDP server/client applications: 2 | Write a UDP server/client application including a connectionless client and a connected client. -------------------------------------------------------------------------------- /Chapter13/P263_ConnectedClient/README.md: -------------------------------------------------------------------------------- 1 | # Writing UDP server/client applications: 2 | Write a UDP server/client application including a connectionless client and a connected client. -------------------------------------------------------------------------------- /Chapter13/P263_ConnectionlessClient/README.md: -------------------------------------------------------------------------------- 1 | # Writing UDP server/client applications: 2 | Write a UDP server/client application including a connectionless client and a connected client. -------------------------------------------------------------------------------- /Chapter13/P265_NetworkInterface/README.md: -------------------------------------------------------------------------------- 1 | # Exploring network interfaces: 2 | Write a snippet of code that displays details about the network interfaces available on your machine. -------------------------------------------------------------------------------- /Chapter13/P266_MulticastClient/README.md: -------------------------------------------------------------------------------- 1 | # Writing a UDP multicast server/client application: 2 | Explain and exemplify the implementation of a UDP multicast-based application. -------------------------------------------------------------------------------- /Chapter13/P266_MulticastServer/README.md: -------------------------------------------------------------------------------- 1 | # Writing a UDP multicast server/client application: 2 | Explain and exemplify the implementation of a UDP multicast-based application. -------------------------------------------------------------------------------- /Chapter13/P267_BlockingEchoClientKEM/README.md: -------------------------------------------------------------------------------- 1 | # Adding KEM to a TCP server/client application: 2 | Explain and exemplify the usage of JDK 21 Key Encapsulation Mechanism for encrypting/decrypting the communication in a TCP server/client application. -------------------------------------------------------------------------------- /Chapter13/P267_BlockingEchoServerKEM/README.md: -------------------------------------------------------------------------------- 1 | # Adding KEM to a TCP server/client application: 2 | Explain and exemplify the usage of JDK 21 Key Encapsulation Mechanism for encrypting/decrypting the communication in a TCP server/client application. -------------------------------------------------------------------------------- /Chapter13/P270_SWSCommandLineTool/README.md: -------------------------------------------------------------------------------- 1 | # Exploring SWS command-line tool: 2 | Provide a step-by-step guide for starting, using, and stopping the SWS via the command line. -------------------------------------------------------------------------------- /Chapter13/P270_SWSCommandLineTool/README.txt: -------------------------------------------------------------------------------- 1 | This folder (/docs) contains the files served by Simple Web Server) -------------------------------------------------------------------------------- /Chapter13/P270_SWSCommandLineTool/docs/books.txt: -------------------------------------------------------------------------------- 1 | List of books: 2 | Java Coding Problems 1st Edition 3 | Java Coding Problems 2st Edition 4 | jOOQ Masterclass 5 | The Complete Coding Interview Guide in Java -------------------------------------------------------------------------------- /Chapter13/P270_SWSCommandLineTool/docs/jOOQ Masterclass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter13/P270_SWSCommandLineTool/docs/jOOQ Masterclass.png -------------------------------------------------------------------------------- /Chapter13/P271_ProgrammaticSWS/README.md: -------------------------------------------------------------------------------- 1 | # Introducing com.sun.net.httpserver API: 2 | Describe the pillars of SWS API. -------------------------------------------------------------------------------- /Chapter13/P271_ProgrammaticSWS/docs/Java Coding Problems 1st Edition.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter13/P271_ProgrammaticSWS/docs/Java Coding Problems 1st Edition.png -------------------------------------------------------------------------------- /Chapter13/P271_ProgrammaticSWS/docs/Java Coding Problems 2nd Edition.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter13/P271_ProgrammaticSWS/docs/Java Coding Problems 2nd Edition.png -------------------------------------------------------------------------------- /Chapter13/P271_ProgrammaticSWS/docs/books.txt: -------------------------------------------------------------------------------- 1 | List of books: 2 | Java Coding Problems 1st Edition 3 | Java Coding Problems 2st Edition 4 | jOOQ Masterclass 5 | The Complete Coding Interview Guide in Java -------------------------------------------------------------------------------- /Chapter13/P271_ProgrammaticSWS/docs/jOOQ Masterclass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter13/P271_ProgrammaticSWS/docs/jOOQ Masterclass.png -------------------------------------------------------------------------------- /Chapter13/P271_ProgrammaticSWSExecutor/README.md: -------------------------------------------------------------------------------- 1 | # Introducing com.sun.net.httpserver API: 2 | Describe the pillars of SWS API. -------------------------------------------------------------------------------- /Chapter13/P271_ProgrammaticSWSExecutor/docs/books.txt: -------------------------------------------------------------------------------- 1 | List of books: 2 | Java Coding Problems 1st Edition 3 | Java Coding Problems 2st Edition 4 | jOOQ Masterclass 5 | The Complete Coding Interview Guide in Java -------------------------------------------------------------------------------- /Chapter13/P271_ProgrammaticSWSExecutor/docs/jOOQ Masterclass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter13/P271_ProgrammaticSWSExecutor/docs/jOOQ Masterclass.png -------------------------------------------------------------------------------- /Chapter13/P271_ProgrammaticSWSFileHandler/README.md: -------------------------------------------------------------------------------- 1 | # Introducing com.sun.net.httpserver API: 2 | Describe the pillars of SWS API. -------------------------------------------------------------------------------- /Chapter13/P271_ProgrammaticSWSFileHandler/docs/books.txt: -------------------------------------------------------------------------------- 1 | List of books: 2 | Java Coding Problems 1st Edition 3 | Java Coding Problems 2st Edition 4 | jOOQ Masterclass 5 | The Complete Coding Interview Guide in Java -------------------------------------------------------------------------------- /Chapter13/P271_ProgrammaticSWSFileHandler/docs/jOOQ Masterclass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter13/P271_ProgrammaticSWSFileHandler/docs/jOOQ Masterclass.png -------------------------------------------------------------------------------- /Chapter13/P271_ProgrammaticSWSFilters/README.md: -------------------------------------------------------------------------------- 1 | # Introducing com.sun.net.httpserver API: 2 | Describe the pillars of SWS API. -------------------------------------------------------------------------------- /Chapter13/P271_ProgrammaticSWSFilters/docs/books.txt: -------------------------------------------------------------------------------- 1 | List of books: 2 | Java Coding Problems 1st Edition 3 | Java Coding Problems 2st Edition 4 | jOOQ Masterclass 5 | The Complete Coding Interview Guide in Java -------------------------------------------------------------------------------- /Chapter13/P271_ProgrammaticSWSFilters/docs/jOOQ Masterclass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter13/P271_ProgrammaticSWSFilters/docs/jOOQ Masterclass.png -------------------------------------------------------------------------------- /Chapter13/P271_ProgrammaticSWSFilters/swslog.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter13/P271_ProgrammaticSWSFilters/swslog.txt -------------------------------------------------------------------------------- /Chapter13/P272_ProgrammaticSWSAdaptRequest/README.md: -------------------------------------------------------------------------------- 1 | # Adapting request/exchange: 2 | Provide a few snippets of code that adapt the SWS request/exchange for custom scenarios. -------------------------------------------------------------------------------- /Chapter13/P272_ProgrammaticSWSAdaptRequest/docs/books.txt: -------------------------------------------------------------------------------- 1 | List of books: 2 | Java Coding Problems 1st Edition 3 | Java Coding Problems 2st Edition 4 | jOOQ Masterclass 5 | The Complete Coding Interview Guide in Java -------------------------------------------------------------------------------- /Chapter13/P272_ProgrammaticSWSAdaptRequest/docs/jOOQ Masterclass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Chapter13/P272_ProgrammaticSWSAdaptRequest/docs/jOOQ Masterclass.png -------------------------------------------------------------------------------- /Chapter13/P273_ProgrammaticSWSComplementHandler/README.md: -------------------------------------------------------------------------------- 1 | # Complementing a conditional HttpHandler with another handler: 2 | Write an example that shows how to conditionally choose between two HttpHandler instances. -------------------------------------------------------------------------------- /Chapter13/P273_ProgrammaticSWSComplementHandler/docs/books.txt: -------------------------------------------------------------------------------- 1 | List of books: 2 | Java Coding Problems 1st Edition 3 | Java Coding Problems 2st Edition 4 | jOOQ Masterclass 5 | The Complete Coding Interview Guide in Java -------------------------------------------------------------------------------- /Chapter13/P274_SWSInMemoryFileSystem/README.md: -------------------------------------------------------------------------------- 1 | # Implementing SWS for an in-memory file system: 2 | Write an SWS implementation that serves resources from an in-memory file system (for instance, Google jimfs in-memory file system or other similar solution). -------------------------------------------------------------------------------- /Chapter13/P275_SWSZipFileSystem/README.md: -------------------------------------------------------------------------------- 1 | # Implementing SWS for a zip file system: 2 | Write a SWS implementation that serves resources from a ZIP archive. -------------------------------------------------------------------------------- /Chapter13/P275_SWSZipFileSystem/docs/books.txt: -------------------------------------------------------------------------------- 1 | List of books: 2 | Java Coding Problems 1st Edition 3 | Java Coding Problems 2st Edition 4 | jOOQ Masterclass 5 | The Complete Coding Interview Guide in Java -------------------------------------------------------------------------------- /Chapter13/P275_SWSZipFileSystem/zips/README.txt: -------------------------------------------------------------------------------- 1 | The docs.zip archive will be created in this folder and it will contain a single file named bookszipped.txt. 2 | The URL is http://localhost:9009/bookszipped.txt -------------------------------------------------------------------------------- /Chapter13/P275_SWSZipFileSystem/zips/docs.zip: -------------------------------------------------------------------------------- 1 | PK -------------------------------------------------------------------------------- /Chapter13/P276_SWSJavaRuntimeDirectory/README.md: -------------------------------------------------------------------------------- 1 | # Implementing SWS for a Java runtime directory: 2 | Write a SWS implementation that serves resources from a Java runtime directory (JEP 220). -------------------------------------------------------------------------------- /Java Coding Problems Second Edition.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Java-Coding-Problems-Second-Edition/47b7c834407a607580baf8e3a23c1c24c24b8bc0/Java Coding Problems Second Edition.png --------------------------------------------------------------------------------