Disclosure: This article may contain affiliate links. When you purchase, we may earn a small commission.

Template Method Pattern in Java? Example Tutorial

Template Method Pattern defines a sequence of steps of an algorithm. The subclasses are allowed to override the steps but not allowed to change the sequence. It can also be provided a default implementation for one or more steps. Let us look at the following example to understand Template Method Pattern.  A Template method pattern provides a skeleton for performing any sort of algorithm or an operation, and it allows the sub-classes to re-define part of the logic. One of the key advantage of Template pattern is that its natural fit for building frameworks, so that parent framework classes can make callbacks into methods implemented in children. Spring Framework makes full examples of Template pattern and you will find several key classes like JdbcTemplate, RestTemplate, and JmsTemplate which are created using Template pattern.

What is Spring Expression Language (SpEL)? Difference between $ and # in @Value expressions Example

Hello Java programmers, if you are wondering what is Spring Expression Language and how to use them in your Spring Framework or Spring Boot application then you have come to the right place. Earlier, I have shared the best Spring Framework coursesFree Spring Questions, Spring projects, and books, and in this article, I am going to teach you about Spring Expression Language with simple, easy-to-understand examples. The Spring Expression Language (SpEL for short) is a powerful language that supports querying and manipulating an object graph at runtime. The syntax is similar to Unified EL, but it has several more features, such as method calling and rudimentary string templating.

Top 23 Object Oriented Design Patterns (GOF) Java Programmers Should Learn

Design Patterns are tried and tested way of solving a problem within a given context. They are not invented, rather they are discovered, which is also obvious by use of word pattern. By using design pattern, you take knowledge of all wide communities and can safely use it to solve that problem. At times they might not give you perfect solution, require bit of tweaking, but they certainly provides one of the best solution, as long as you use them properly. While doing object oriented development, they are numerous task which appears quite often e.g. creating objects, structuring code, and implementing different behaviors based on different context.

Student Management System Project - FullStack Java + Spring Boot + React.js Example Tutorial

Hello Java programmers, if you want to learn Spring Boot and Reactjs and looking for a full-stack Java example or a mini project then you have come to the right place. Earlier, I have shared the best Spring Boot coursesbooks, and best reactjs courses as well as many courses to learn full-stack development in Java and become a full-stack java developer. In this mini project, you will learn how to create an application that is capable of creating, deleting, updating, and retrieving functions using the Spring Boot, React, and H2 Database. In this tutorial you will create a School Classroom Application that can insert, update, delete and search students. The frontend of the application is developed using Reactjs and also the backend is developed using spring boot. And, most importantly communication between the two platforms will be done using the REST APIs. 

How to merge two HashMap in Java 8 - Map.merge() example

You can merge two Map in Java using the newly added merge() function in Java 8. This allows you to copy values from one map to another to merge both of them. It also provide a lot of flexibility to handle duplicate keys. In the last article, I have shown you how to combine two Map in Java using the putAll() method but there was a problem. If a key is present in both map, then putAll() overrides the value from the second map, which you may or may not want. The real issue is that you don't have any control on what should happen if there exists duplicate keys in those Map e.g. you may want to keep the original value intact or you always want values from second map to override values in first map, or you just want to concat or add two values to form a new value. This problem is solved by the Map.merge() method in JDK 8, which allows you to pass a lambda expression to control the remapping operation.

How to create RESTful Web Services in Java using Spring Boot? Example Tutorial

Hello guys, if you are looking for a complete tutorial to create REST API on Spring Boot then you have come to the right place. In the past, I have shared the best RESTful Web Services courses and best Spring Boot courses and in this article, I am going to show you how to create RESTful web services using Spring Boot step by step. After going through this tutorial you will be able to create your own REST endpoints and RESTful application using Spring Boot and Spring Framework and Java programming language. How to make Spring boot REST API? is a common question that everyone has who is new to Spring boot application development. 

How to use Lombok in Java? Lombok @Data and @NonNull Annotations Examples

Hello Java programmers, if you have been doing professional Java development, you may have heard about Lombok library, one of the most popular Java libraries among professional Java developers, making coding in Java much more fun and rewarding. Java has always been criticized for its verbosity, and many programming languages like Scala and Groovy are invented to solve that problem, but Lombok solves that problem in Java itself. This means you don't need to learn a new programming language, but you can use the Lombok library and its annotations to write clear and concise code in Java. 

How to use NamedQuery in Spring Framework JDBC? Example Tutorial

Hello guys, many people don't know that Spring Framework provides support for NamedQuery where you can pass parameters in a much readable way by using named placeholders than the default placeholder of ? (question mark) which is used with PreparedStatement in Java. If you want to learn Spring JDBC then you have come to the right place. In the past, I have shared the best Spring Framework courses, books, and tutorials to learn Spring Framework and its different features, and in this example, I will show you how to use NamedQuery in Spring Framework. You can then use this technique to write much more readable queries on the Java layer for your application. 

10 Data Structures Every Programmer Should Learn

Data Structure and Algorithms are two pillars of Programming. They are also the most important ingredient of a good program and right choice of Data Structure and Algorithms can improve performance drastically, whereas a wrong choice can spoil the party, but do you know what exactly they are? Well, Data Structure are nothing but a way to store data, while Algorithms are ways to operate on that Data. There is a reason why Data Structure and Algorithms are taught in every single Computer Science classes, it doesn't matter whether you are learning Java, C++, Python, JavaScript, Golang, or any other programing language, those data structure and algorithm will be same everywhere. 

How to upload/download file in Spring MVC and Spring Boot Java application? Example Tutorial

Hello guys, if you are wondering how to upload file and download files from a Spring MVC application then you have come to the right place. This is an important functionality for any real-world application and knowing how to upload a file in a Spring application is important for professional Java developers and that's what you will learn in this Spring MVC tutorial. Earlier, I have shared several Spring Boot tutorial like Spring Boot + Microservices, and Spring Boot + REST and even  how to upload files using Servlet and JSP using Apache Commons FileUpload library and In this tutorial, we are going to discuss how to upload and download files using Spring MVC. 

How to use Mockito to Unit test Java Program with JUnit? Example Tutorial

Hello guys, if you are writing unit test your Java application then you would have definitely come across JUnit and Mockito, two of the essential unit testing framework  for Java developers. While JUnit offers support to run your test, setup and teardown and also assertion to check the expected and actual output. Mockito complements JUnit by offering you a mock based testing approach. Mock is nothing but a test double which can return a configured value when a certain method is called. It also provides ability to check if a particular method is called or not. By using Mock object or test double you can check if your code is behaving properly or not in different scenarios. This is also the key difference between JUnit and Mockito, JUnit provides infrastructure to run your test while Mockito provide infrastructure to created Mock objects.