Spring Boot and Ehcache 3 Example
Learn to configure Ehcahce 3 with Spring Boot 2.x and Spring Boot 3.x applications, use @Cacheable annotation and log caching events.a
Learn to configure Ehcahce 3 with Spring Boot 2.x and Spring Boot 3.x applications, use @Cacheable annotation and log caching events.a
Learn the different ways of counting the number of vowels and consonants in a given string using the Java 8 Streams and simple iteration.
In these java programs, learn to reverse the words of a string in Java without using api functions. We can reverse the words of string in two ways: Reverse each word’s characters but the position of word in string remain unchanged. Reverse the string word by word but each word’s …
Learn to sort an array of strings alphabetically. In given java program, strings are given as input from console and after sorting – printed in the console.
In regex, we can match any character using period “.” character. To match only a given set of characters, we should use character classes.
Regular expressions, commonly referred to as regex, are powerful tools for pattern matching and manipulation of text. The regex patterns enable developers to perform intricate string searches, substitutions, and validations. Among the plethora of regex features, line anchors are the key components for precisely identifying the beginning or end of …
Learn to swap two numbers in given two Java programs. First program uses a temporary variable while second program does not uses any temp variable.
Learn to write program to find first prime numbers using Java 8 Stream API, where N is any given input number to the application.
Learn to write program for finding all the prime numbers from 1 and N, using Java 8 stream API, where N is any given input number to the application.
Learn about an efficient algorithm to determine a given number is prime or not. Also learn to implement prime number algorithm in Java 8 program.
Learn to have optional @PathVariable valuein spring mvc application when required attribute to set to false or expect variable’s value to null.
Learn to build Spring boot web applications supporting CRUD operations through form-based UI built on thymeleaf and spring mvc support.
Learn to request partial data from the database using pagination and sorting inputs using the query parameters in spring boot and data apps.
Learn to build a robust Spring Boot application with Hibernate, covering CRUD operations, paging, filtering, caching, and best practices.
Learn to configure hibernate/JPA support in Spring Boot2 applications, along with creating entity classes and extending inbuilt JpaRepository interfaces.
Learn to modify the default embedded tomcat configurations via override respective properties in application.properties file in spring boot application.
Learn to configure Spring boot with H2 database to create and use an in-memory database in runtime, generally for unit testing or POC purposes.
Learn to enable and customize the internal and access logs generated for embedded servers in Spring boot e.g. tomcat, jetty & undertow.
DelayQueue class is an unbounded blocking queue of delayed elements, in which an element can only be taken when its delay has expired.
Learn ExecutorService shutdown(), shutdownNow() and awaitTermination() APIs and how to use them correctly to shutdown executor under different conditions,
Learn to cancel a task submitted to an executor service that still has to be executed not completed yet using Future.cancel() API.
Learn to execute a task after a period of time or execute it periodically using ScheduledExecutorService class in Java using ScheduledThreadPoolExecutor.
Learn to run multiple Callable tasks with ExecutorService.invokeAll(tasks) API and processing all the results returned from tasks in form of Future class instances in this ExecutorService Callable example.
Learn to use ExecutorService invokeAny() method where we execute multiple tasks at same time, but we make a decision asap any one of tasks is completed.
Learn to handle tasks which are submitted to Executor and are rejected because the executor has been shutdown for any reason using RejectedExecutionHandler. 1. When tasks get rejected Remember when we finish the execution of an executor, we use the shutdown() method. The executor waits for the completion of tasks …
Learn to use Java ExecutorService to execute a Runnable or Callable class in an asynchronous way. Also learn the various best practices to utilize it in most efficient manner in any Java application.
Learn to apply locale-sensitive compact/short number formatting to general purpose numbers e.g. decimal, currency, and percentage. It is added in Java 12 in CompactNumberFormat class.
Learn to indent (left indentation) a string(s) in Java using String.indent() API. This api has been introduced in Java 12.
Learn to convert multi-line string into stream of lines using String.lines() method in Java 11. This method is useful when we want to read content from a file and process each string separately.
Learn to write a string into file in Java using Files.writeString(path, string, options) method. This API has been introduced in Java 11.
Learn to read a file to string in Java using Files.readString(path) method. This API has been introduced in Java 11.
Learn to use String.isBlank() method to determine is a given string is blank or empty or contains only white spaces. isBlank() method has been added in Java 11.
Learn to use String class’s strip(), stripLeading() and stripTrailing() methods to remove unwanted white spaces from a given string in Java 11.
Learn to repeat a given string N times, to produce a new string which contains all the repetitions, though a simple Java program using String.repeat() api.
Learn about Collectors.teeing() method (added in Java 12), method syntax and how to apply teeing() method in various usecases in Java.
Java 11 (released on September 2018) includes many important and useful updates. Let’s see the new features and improvements, it brings for developers and architects. 1. HTTP Client API Java had HttpURLConnection class for long time for HTTP communication. But over the time, requirements have gone complex and more demanding …
Java 12 (released on March 19, 2019) is latest version available for JDK. Let’s see the new features and improvements, it brings for developers and architects.
Learn to write a simple java program to verify if a given number is deficient number or not. The value 2n − σ(n) is called the number’s deficiency.
A pronic number is a number which is the product of two consecutive integers, that is, a number of the form ‘n x (n + 1)’.
Learn to write a simple java program to verify if a given number is harshad number or not.
Learn to write a simple java program to verify if a given number is happy number or not.
Write a simple java program to verify if a given number is disarium number or not.
Learn to pass and retrieve the command line arguments in a Spring boot application using ApplicationArgument injection and @Value annotation.
Return 403 access denied response in jSON in REST API where principal should be pre-authenticated but is null in AbstractPreAuthenticatedProcessingFilter.
Learn to handle the HTTP OPTIONS requests specific to REST resource in Spring WebMVC applications by adding handler methods.
Learn to validate the request body of a REST API built with Spring MVC. Also, validate @PathVariable and @RequestParam parameters in resource URIs using the hibernate validator framework. In this Spring MVC validation example, we will add validations in REST APIs created for the CRUD example. 1. Request Body Validation …
Learn to add custom token based authentication to REST APIs using created with Spring REST and Spring security 5. In given example, a request with header name “AUTH_API_KEY” with a predefined value will pass through. All other requests will return HTTP 403 response.
Learn to compare two LocalDateTime instances to find out which date represents an older timestamp in comparison to other timestamp. LocalDateTime class is part of java.time package added in Java 8.
Learn to handle exceptions locally and globally in Spring Boot REST APIs using @ControllerAdvice, @ExceptionHandler, and other latest approaches.
Learn to create REST APIs for crud operations using Spring REST and JPA configuration (H2 database as backend) without Spring boot auto configuration feature.
HowToDoInJava provides tutorials and how-to guides on Java and related technologies.
It also shares the best practices, algorithms & solutions and frequently asked interview questions.