Return to site

[VV120] The Java 21 Newsletter

June 12, 2025

๐Ÿ›ฃ๏ธโ˜•2๏ธโƒฃ1๏ธโƒฃ Dear followers, let's prepare for Java 21 certification together!

  • โžฟ For loop body
  • ๐Ÿ’พ Records members
  • โŒ› Period
  • ๐Ÿฆฎ record guideline

#vvauban #newsletter #java #java21

QUESTION 1๏ธโƒฃ

How would you answer this question:

Given:

What will be printed?

A) 0 1 2

B) 1 2

C) 1 2 3

D) It throws an exception at runtime.

E) Compilation fails.

#PathToJava21 #java #certification

๐Ÿ’ก Solution

Let's walk through it carefully:

The given code is:

In a for loop, the structure is:

Here:

๐ŸŸฃ Initialization: var i = 0

๐ŸŸฃ Condition: i ใ€ˆ 3

๐ŸŸฃ Update: System.out.print(i + " ")

๐ŸŸฃ Body: i++

Step-by-step execution:

1) i = 0

2) Check i ใ€ˆ 3 โ†’ 0 ใ€ˆ 3 โ†’ true

3) Execute body: i++ โ†’ i = 1

4) Update step: System.out.print(i + " ") โ†’ prints 1

5) Back to condition check: i = 1

6) Check i ใ€ˆ 3 โ†’ 1 ใ€ˆ 3 โ†’ true

7) Execute body: i++ โ†’ i = 2

8) Update step: System.out.print(i + " ") โ†’ prints 2

9) Back to condition check: i = 2

10)Check i ใ€ˆ 3 โ†’ 2 ใ€ˆ 3 โ†’ true

11)Execute body: i++ โ†’ i = 3

12)Update step: System.out.print(i + " ") โ†’ prints 3

13)Back to condition check: i = 3

14)Check i ใ€ˆ 3 โ†’ 3 ใ€ˆ 3 โ†’ false

15)Loop exits.

Thus, the output is:

1 2 3

Answer: โœ… C) 1 2 3

(Controlling Program Flow)

LESSON 1๏ธโƒฃ

๐ŸŽฌ Java Record Classes Explained with French Actors! ๐Ÿ‡ซ๐Ÿ‡ท | Custom Accessors, Static Members & More ๐Ÿง‘๐Ÿ’ป

In this fun and practical Java tutorial, we dive into the world of record classes using a cinematic twist โ€” featuring French actors as our data models! ๐ŸŽฅ

You'll learn:

โœ… How to declare and customize accessor methods

โœ… What static members are (including static fields & methods)

โœ… What you cannot do in records โŒ

โœ… How to use nested record classes and instance methods

โœ… What a native method is โ€” and why itโ€™s not allowed in records! โš ๏ธ

From Marion Cotillard to award-winning code examples ๐Ÿ†, this video is a perfect blend of Java fundamentals and creative learning!

๐Ÿ‘จ๐Ÿซ Great for beginners and intermediate Java developers!

๐Ÿ“š Code examples included

๐Ÿ› ๏ธ Real-world analogies

๐ŸŽ“ Learn faster with themed examples

๐Ÿ‘‡ Don't forget to like, comment, and subscribe if you enjoy coding with a touch of French cinema!

#Java #RecordClass #JavaTutorial #FrenchCinema #JavaProgramming #LearnJava #JavaRecords #MarionCotillard #CodingWithStyle #JavaDev #DeveloppeurJava #ProgrammationJava #CodingTutorial #JavaBeginner #CodeWithMe ๐ŸŽฅ๐Ÿ’ป๐Ÿฟ

QUESTION 2๏ธโƒฃ

How would you answer this question:

Given:

What will be printed?

A) P1Y12M1D

B) P1Y13M1D

C) P2Y1M1D

D) It throws an exception at runtime.

E) Compilation fails.

#PathToJava21 #java #certification

๐Ÿ’ก Solution

Let's walk through it carefully:

You have:

๐ŸŸฃ Period.of(1, 13, 1) means 1 year, 13 months, and 1 day.

๐ŸŸฃ normalized() adjusts months to be within 0-11 by converting extra months into years.

- 13 months โ†’ 1 year and 1 month (because 12 months = 1 year).

๐ŸŸฃ So 1 year + 1 year = 2 years, and you still have 1 month and 1 day.

Thus, after normalization, the result is:

P2Y1M1D

Final Answer:

โœ… C) P2Y1M1D

(Controlling Program Flow)

LESSON 2๏ธโƒฃ

Avoid in-line text blocks within complex expressions, as doing so can distort readability. Consider refactoring to a local variable or to a static final field.