Posts in category 'programming'

Replace OAuth2RestTemplate with RestClient: A Modern Spring Boot API Client

In the previous post, we built a program that walks an Order API (buyers, suppliers, customer numbers, articles) and places a test order. It works, but it’s built on OAuth2RestTemplate,...

Break Out of Nested Loops in Java: Automating a Real REST API Client

Testing an order API by hand means clicking through buyers, suppliers, customer numbers and articles until you find a combination that works. This program does it in seconds: it walks...

Log Every Login Attempt with Spring Boot Actuator Auditing

When a login fails at 3 a.m., you want to know who tried, how often, and whether it worked. Spring Boot Actuator already publishes these security events; you only have...

Java OCP Practice Questions: Building Blocks, with Answers Explained

The OCP Java exam doesn’t test whether you can write code. It tests whether you can read code like a compiler: which line fails, what exactly gets printed, which object...

Java Bit Flags with Enums: Combine, Check and Decode Errors with Bitwise Operators and EnumSet

An order API has to report several problems at once: a wrong quantity, a price difference and an article that no longer exists. Sending a list of strings works, but...

Java Generics Explained: Wildcards, PECS and Type Erasure with Examples

Before Java 5, every collection held Object, and every value you took out needed a cast, which could fail at runtime. Generics moved that check to the compiler. Here’s how...

Functional Programming in Java: Lambdas, Streams, Records and Immutability

You already use functional programming in Java every time you write a lambda or a stream. Used well, it turns a 20-line loop over orders into five readable lines. Used...