Java

In this tutorial, we will generate a random alpha-numeric string of characters, which can be used as a user password. Password Requirements When generating passwords, it’s important to set requirements that make them strong and difficult to guess. Here are some guidelines to follow when creating password requirements: Length The length of a password is…

Read More Generate Secure Password in Java

This tutorial will teach you how to use project Lombok in the Spring Boot application. Overview No doubt Java is a wonderful language, but one of the drawbacks of Java is its verbose nature. This makes it fairly complicated for everyday tasks such as composing a simple POJO object. For example, constructing of methods like Getters(), Setters(),…

Read More How to use Project Lombok in Spring Boot

This tutorial will teach you how to add Spring Security to your project and enable in-memory basic authentication. You will learn how to configure two different users with different Roles and Privileges. Both users’ roles and privileges will be stored in the memory of your Spring Boot application. If you use Spring Framework and OAuth,…

Read More Spring Security In-Memory Authentication

Introduction Linked lists are an important data structure used in programming. They are especially useful when the size of the data is unknown and dynamic, or when we want to implement other data structures like stacks and queues. In this tutorial, we’ll focus on singly linked lists (SLL), one of the most commonly used linked…

Read More Singly linked list in Java

In this tutorial, you will learn how to write a JUnit test that validates whether the method under test throws the correct exception. The tutorial includes examples for both JUnit 5 and JUnit 4. For video lessons, check out my video course: Testing Java with JUnit and Mockito. Let’s begin with JUnit 5 version first.…

Read More Test for Exception in JUnit 5 and JUnit 4

Introduction A Doubly Linked List (DLL) is a data structure in which each node of the list contains a pointer to its previous and next nodes. This allows bidirectional traversal of the list. In this tutorial, we will discuss the representation, advantages, and disadvantages of using a DLL over a singly linked list, operations on…

Read More Doubly Linked List in Java

In this tutorial, I am going to share with you a few different techniques you can use to iterate over a collection in Java. Iterating ArrayList with Enhanced For-Loop List<String> names = new ArrayList<>(); names.add(“Sergey”); names.add(“Bill”); names.add(“John”); for(String name: names) { System.out.println(name); } Output: Sergey Bill John We declare a List of String objects named…

Read More Iterating over Collections in Java: Examples

Optional<T> findFirst() class Test { public static void main(String[] args) { List<Integer> numbers = new ArrayList<>(Arrays.asList(3, 7, 9, 12)); Optional<Integer> resultOptional = numbers.stream().findFirst(); if (resultOptional.isPresent()) { // checking if Optional contains any value System.out.println(“The first element in the stream is: ” + resultOptional.get()); // getting the value from Optional } else { System.out.println(“The stream is…

Read More Streams – findFirst() operation

Learning how to convert Java objects into JSON and vice versa can be very helpful for your work as a full-stack mobile app developer. In this blog post, I will share some code examples that will help you with the most common tasks you’ll encounter when working with JSON and Java. I will cover the…

Read More Convert Java into JSON and JSON into Java. All Possible Examples.

In this Spring Security tutorial, you will learn how to enable Basic Authentication for your Spring Boot project and configure the default username, password and user role. You will also learn how to secure a web service request URL so only authenticated users with a default username, password and role can access it. If you use…

Read More Spring Security Default Username, Password, Role