yellow racing car with the words code performance

Caching in Wrapper Classes

Here’s a fact that you may not know. When you auto-box integral primitives (byteshortint and long) to their respective wrapper classes (ByteShortInteger and Long), the wrapper classes cache all values from -128 to +127. These values are later used by the valueOf() methods to give better performance than using a constructor.

Continue reading
Squirrel monkey in a tree eating a cookie

Who stole the cookies?

No, we are not talking about delicious double-chocolate cookies. Although I’ve really missed the fabulous Incus Data cookies during lockdown.

As you know, cookies are small text files. They are usually created by the web server, but are saved and managed by your browser.

Cookies can be harmless or incredibly dangerous. It all depends on how you use them.

Continue reading
Carton of eggs with one broken egg

One broken egg…

I believe in code re-use. You believe in code re-use. No-one wants to re-invent the wheel, especially not if there is a really great, aero-dynamic, ultra-fast wheel available.

That’s why we use libraries and components. But those libraries and components are not written by super-humans. They are written by people like you and me – people who make mistakes.

Continue reading
Signpost with the words Consumer and Supplier

Your guide to the standard Java functional interfaces

Last week I wrote about functional interfaces and how to use them as targets for lambda expressions. I showed you how we create a variable of a functional interface type and assign a lambda expression to it. Today I want to help you make sense of the set of standard functional interfaces.

Continue reading