[VV91] Java22 for dev, Java Between, TextBlock delimiters, Kubernetes, memento pattern, Kafka Avro compatibility modes
[VV91] The Java Fullstack Newsletter

[VV91] Java22 for dev, Java Between, TextBlock delimiters, Kubernetes, memento pattern, Kafka Avro compatibility modes

?????Java 22 features for developers

Java 22, released on March 19, 2024, introduced several exciting features and enhancements. Here are some of the key highlights:

??? ?????????????? ?????????????????? & ???????????????? (?????? ??????):

This feature allows for more concise code by using an underscore (_) for variables that are not used, such as in lambda parameters or catch blocks.

???? ???????????? ??????????-???????? ????????????-???????? ???????????????? (?????? ??????):

With this feature, you can run programs consisting of multiple .java files without compiling them in advance.

?? ???????????????????? ???????????? ?????????? (??????????????, ?????? ??????):

This allows code to be executed in constructors before calling super(...) or this(...), with some restrictions.

?? ???????????? ?????????????????? (??????????????, ?????? ??????):

This addition provides a new way to write intermediate stream operations.

?? ?????????????? ???????????????? & ???????????? ?????? (?????? ??????):

After several rounds of incubation and preview, this API has been finalized, offering a standardized way to interact with native code and memory.

?? ???????????????????? ?????????????????????? (???????????? ??????????????, ?????? ??????):

This feature simplifies concurrent programming by treating multiple tasks running in different threads as a single unit of work.

?? ???????????? ???????????? (???????????? ??????????????, ?????? ??????):

Scoped values introduce a new way to manage shared data within a thread or across child threads.

?? ???????????? ?????????????????? (???????????? ??????????????, ?????? ??????):

This feature enhances string manipulation and formatting capabilities.

???? ???????????????????? ???????????????? ?????????????? ?????? ???????????????? ???????? ?????????????? (???????????? ??????????????, ?????? ??????):

Renamed from "Unnamed Classes and Instance Main Methods," this feature has been revised and provides a way to declare classes and main methods implicitly.

These features aim to improve developer productivity, code readability, and application performance.

#java #java22 #features

https://openjdk.org/projects/jdk/22/




???JAVA CERTIFICATION QUESTION: Between

Given:

Period p = Period.between( 

        LocalDate.of( 2023, Month.MAY, 4 ), 

        LocalDate.of( 2024, Month.MAY, 4 ) );

System.out.println( p );

Duration d = Duration.between( 

        LocalDate.of( 2023, Month.MAY, 4 ), 

        LocalDate.of( 2024, Month.MAY, 4 ) );

System.out.println( d );        

What is the output?

A)

P1Y

PT8784H

B)

PT8784H

P1Y

C)

UnsupportedTemporalTypeException

D)

P1Y

UnsupportedTemporalTypeException

E)

PT8784H

UnsupportedTemporalTypeException

#java #certificationquestion #ocp

https://www.udemy.com/course/ocp-oracle-certified-professional-java-developer-prep/?referralCode=54114F9AD41F127CB99A

The output is:

P1Y

java.time.temporal.UnsupportedTemporalTypeException: Unsupported unit: Seconds

at java.base/java.time.LocalDate.until(LocalDate.java:1636)

at java.base/java.time.Duration.between(Duration.java:489)

Period works well with LocalDate, while Duration no.

Because duration works with Time and according to JavaDoc:

"The specified temporal objects must support the SECONDS unit. For full accuracy, either the NANOS unit or the NANO_OF_SECOND field should be supported."

Duration javadoc: https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html#between(java.time.temporal.Temporal,java.time.temporal.Temporal)

Period javadoc: https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Period.html#between(java.time.LocalDate,java.time.LocalDate)




???JAVA CERTIFICATION QUESTION: TextBlock delimiters

Given:

String textBlock = """
                 j \
                 a \t
                 v \s
                 a \
                 """;
System.out.println(textBlock.length()+" "+textBlock.split("\\n").length);
System.out.println(textBlock.length());        

What is the output?

10

11

12

14

#java #certificationquestion #ocp

https://www.udemy.com/course/ocp-oracle-certified-professional-java-developer-prep/?referralCode=54114F9AD41F127CB99A

Let's decompose this text block.

The first line is 'j \': a letter 'j', a space ' ', and an escaping end line '\' (so no break line).

So this first line has a length of 2.

The second line is 'a \t': a letter 'a', a space ' ', a tab '\t', and a break line '\n' (implicit).

So this second line has a length of 4.

The third line is 'v \s': a letter 'v', a space ' ', a space '\s', and a break line '\n' (implicit).

So this second line has a length of 4.

The fourth line is 'a \': a letter 'a', a space ' ', and an escaping end line '\' (so no break line).

So this second line has a length of 2.

Oracle Java text block documentation: https://docs.oracle.com/en/java/javase/15/text-blocks/index.html#that-final-new-line




??? QUOTE

Always do your best; it's the best way to improve your skills.



?? What is Kubernetes? An Unorthodox Guide for Developers

????????????????????????

????????????, ???????????? ?????????????? & ??????????: ?? ??????????

???????????????????? ??????: ???????????? & ????????????????

????????????????????: ???????????????????? ????????????

#devops #kubernetes #guide #devops #programming




?? DESIGN PATTERN: The quiz!

The _____ Pattern is a design pattern that captures and externalizes an object's internal state,

allowing it to be saved and restored later.

It's often used for implementing undo and redo features in applications.

* Pipeline

* Chain of responsibility

* Command

* Memento

#design #pattern #programming #memento #software

https://www.udemy.com/course/master-software-design-patterns-questions-and-full-answers/?referralCode=D6366BB829DB93970447

The Memento Pattern is a behavioral design pattern in software development that allows you to capture and externalize an object's internal state without exposing its internal structure. This enables you to save and restore the object's state at a later time, providing a way to undo or revert changes.

Key components of the Memento Pattern:

1) Originator: The Originator is the object whose state needs to be saved. It creates a Memento object to represent its state and can restore its state from a Memento.

2) Memento: The Memento is an object that stores the state of the Originator. It has methods to get and set the state but does not reveal the internal details of the Originator.

3) Caretaker: The Caretaker is responsible for keeping track of and managing Memento objects. It can save and retrieve the Originator's state using Mementos.

The Memento Pattern is particularly useful for implementing features like undo and redo functionality in applications, as well as for managing checkpoints and history in various systems. It allows you to capture an object's state at specific points in time and restore it as needed, all while keeping the object's internal details hidden.

https://en.wikipedia.org/wiki/Memento_pattern

https://refactoring.guru/design-patterns/memento




??Understanding Kafka Avro Compatibility: FORWARD, BACKWARD, and FULL

When dealing with Kafka and Avro, schema compatibility is crucial.

Compatibility types dictate how schema evolution is handled.

Let’s delve into the three main compatibility kinds: FORWARD, BACKWARD, and FULL.

? FORWARD Compatibility

FORWARD compatibility is ideal when producers need to evolve without waiting for consumers to update.

? BACKWARD Compatibility

BACKWARD compatibility is best when consumers need to evolve without waiting for producers to update.

?? FULL Compatibility

FULL compatibility offers the greatest flexibility but requires careful management to avoid breaking changes.

#kafka #avro #compatibility #forward #backward #full




??chair.exe has stopped working ???

chair.exe has stopped working


Yat Yan Ng

Assistant Project Manager

9 个月

Foreign function api. ??

要查看或添加评论,请登录

Vincent Vauban的更多文章

  • [VV111] The Java 21 Newsletter

    [VV111] The Java 21 Newsletter

    ????2??1?? Dear followers, let's prepare for Java 21 certification together! 1?? How would you answer this question:…

    17 条评论
  • ?? Broken Authentication – API2:2023 ??

    ?? Broken Authentication – API2:2023 ??

    I'm kicking off a series of articles on API Security ?? to help us—developers ????????—better understand and implement…

  • ?? BOLA – The #1 API Security Threat (API1:2023)

    ?? BOLA – The #1 API Security Threat (API1:2023)

    I'm kicking off a series of articles on API Security ?? to help us—developers ??????????—better understand and…

  • [VV110] The Java 21 Newsletter

    [VV110] The Java 21 Newsletter

    ????2??1?? Dear followers, let's prepare for Java 21 certification together! 1?? How would you answer this question:…

  • ?2??4?? Java 24 features with Thiago

    ?2??4?? Java 24 features with Thiago

    (Thanks Thiago Gonzaga ) Here are some insights based on Thiago X content. Java 24: JEP 491 Boosts Virtual Threads! ??…

  • [VV109] The Java 21 Newsletter

    [VV109] The Java 21 Newsletter

    ????2??1?? Dear followers, let's prepare for Java 21 certification together! 1?? How would you answer this question:…

  • [VV108] The Java 21 Newsletter

    [VV108] The Java 21 Newsletter

    ????2??1?? Dear followers, let's prepare for Java 21 certification together! 1?? How would you answer this question:…

    2 条评论
  • [VV107] The Java 21 Newsletter

    [VV107] The Java 21 Newsletter

    ????2??1?? Dear followers, let's prepare for Java 21 certification together! 1?? How would you answer this question:…

  • Communication Efficace #french

    Communication Efficace #french

    J'ai eu la chance de suivre un cours de communication grace à Zenika, une entreprise qui accorde une grande importance…

  • [VV106] The Java 21 Newsletter

    [VV106] The Java 21 Newsletter

    ????2??1?? Dear followers, let's prepare for Java 21 certification together! 1?? How would you answer this question:…

社区洞察

其他会员也浏览了