Skip to content


Java LinkedList

The question which often arises is: are LinkedList preferable to ArrayList? In which case should I use it?

As explained in the Java documentation, LinkedList is:

  • A doubly-linked chain: elements are stored in nodes, with linking back and forth between themselves,
  • Mutable: objects can be added and/or removed,
  • Not Thread-safe: LinkedList is not suitable for concurrent access. See Thread Safety for more information.

Let's explore how to use a LinkedList through simple code examples! And find out when a LinkedList instead of an ArrayList should be used.

Java Math.pow Through Code Examples

I'm sure you have already experienced odd results when calling Math.pow method. I know, I've been there too!

Math.pow(double a, double b) returns the value of a raised to the power of b.

It's a static method on Math class, which means you don't have to instantiate a Math instance to call it. The power of a number is the number of times the number is multiplied by itself.

Securing a Rest API with Spring Security

Most Spring Tutorials available online teach you how to secure a Rest API with Spring with examples which are far from real application problematics. You surely agree that most tutorials lack real-world use-cases.

This tutorial aims to help you secure a real-world application, not just another Hello World Example.

In this tutorial we'll learn:

  • How to secure a Spring MVC Rest API using Spring Security,
  • Configure Spring Security with Java code (no painful XML),
  • And delegate authentication to a UserAuthenticationService with your own business logic.

I've spent several weeks tweaking Spring Security to come up with this simple setup. Let's go!

Complete Source code is available on Github.

Spring Boot Rest Tutorial

I'm sure you're looking for a complete Spring Rest Tutorial which covers the most important topics related to Spring Boot. You're in the right place!

You want to build a web application or a REST API using Spring Boot (and other popular technologies like Thymeleaf), but you don't know where to start... Let me help you get things done. This tutorial explains how to create a simple Rest Api exposing data as Json.

Don't worry, Spring isn't that difficult! In under 5 minutes, you will build your first web app using Spring Boot.

NOTE: Updated with Spring Boot 2 and Spring 5!

Full source code is available at Spring Boot 2 Demo on Github.

Spring Circular Dependencies

I know you've been there, like me:

  • I Have a circular dependency in Spring and my application fails to launch. How to solve this?

The typical exception thrown by Spring is the following:

'': Requested bean is currently in creation: Is there an unresolvable circular reference?

And, It does not give much details. So, let's see how we can break the circular dependency cycle and save some sanity!