https://www.gravatar.com/avatar/306d401b2a8c0efe0996fec60e0c90aa?s=240&d=mp

My coding journey

Hello!

My name is Kamila. Let me welcome you on my homepage kamilachyla.com


You will find here a handful of my notes.

I write mainly about programming (EN/PL) (Java, Python, Go, JavaScript), play with generative art using p5js and I'm an author and illustrator of my children's books.

Have fun!

How to avoid switch statement in Spring Boot

In this guest post Norbert Tusiński writes on how to execute different type of behavior in situations where the type of behavior is determined by the value of some `Enum` variable. Immediate intuition is to use switch statement, however Norbert shows other possible solutions in the context of Spring Boot framework.

If not ThreadLocal then what? ScopedValue!

What is a ScopedValue? ScopedValue is a value that can be seen and used in methods, but hasn’t been passed to them as a parameter. Untill recently this was possible in Java language by means of ThreadLocal variables. Let’s look at ThreadLocals for a moment to refresh our knowledge and let’s see what new features are being introduced by newer replacements, that is: ScopedValues. What is the ThreadLocal variable? ThreadLocal variables are typically declared as private global variables (static fields) and ensure that the value we read from them (using the get() method) is the same value that was previously stored in them (using the set() method) within the same thread (or the one returned by calling the protected initialValue() method that returns the initial value of the ThreadLocal variable).

What's new in Java 21?

Java 21 This is a real thing! Java 21 feels almost as a different programming language! Changes planned to be released in Sptember 2023 (in just a month!) can be roghly grouped into two categories: Language and library changes Here are the most important and - in my opinion - the most interesting changes that await us in Java 21. They are not revolutionary, but they make writing code - and, what is even more important, reading it - much easier.

Java 21 - how to install early_access version

I want to try Java 21! Its easy! You can easily try out the new features in Java 21 that I wrote about in the previous post. You don’t need to install anything. Just follow these steps: Download and unzip the archive. Set the JAVA_HOME variable to point to it. Add the /bin subdirectory to your PATH variable. Let’s do it step by step Here’s how to do it in Ubuntu Linux:

Virtual Threads in Javia 21

A bit of history Java has allowed concurrent programming since version 1.0 through the use of the Thread class. This capability was introduced in 1996 (I celebrated my 18th birthday that year!), but it quickly became evident that it wasn’t straightforward. Larger and more complex applications required better tools to handle threads. The standard Java library lacked essential constructs for modeling certain concurrent programming patterns, and the code was often hard to read and prone to errors.

Extracting data from Excell

Excell files circulate in the veins of large companies. Ther are times when you want to extract some data and you have to use Java language for this purpose. Let’s see how to quickly extract data from .xls or .xlsx files using Apache POI library. The library Maven coordinates of the library(ies) can be found here: https://mvnrepository.com/artifact/org.apache.poi. Note that there are two types of excel spreadsheet formats and apache-poi project has two of its most important libraries to handle these data: