Administrator

Lokesh Gupta

A fun-loving family man, passionate about computers and problem-solving, with over 15 years of experience in Java and related technologies. An avid Sci-Fi movie enthusiast and a fan of Christopher Nolan and Quentin Tarantino.

Website: https://howtodoinjava.com

Github: https://github.com/lokeshgupta1981/

Twitter: @HowToDoInJAVA

LinkedIn: https://www.linkedin.com/in/lokeshgupta1981/

My Articles:

Spring Boot Console Logging

Learn to use and configure logging to console in spring boot application. Also learn to configure and use console appenders available in logback and log4j2.

Spring Boot Logging with Lombok

Project lombok can also be used to configure logging in spring boot applications and thus removing the boilerplate code for getting the logger instance.

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

Count Vowels and Consonants in Java

Learn the different ways of counting the number of vowels and consonants in a given string using the Java 8 Streams and simple iteration.

Java program to reverse words in string without using functions

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 …

Regex – Match Any Character(s)

In regex, we can match any character using period “.” character. To match only a given set of characters, we should use character classes.

Regex – Match Start or End of String (Line Anchors)

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 …

Java program to swap two numbers

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.

Spring WebMVC Optional @PathVariable

Learn to have optional @PathVariable valuein spring mvc application when required attribute to set to false or expect variable’s value to null.

Configure Hibernate with Spring Boot

Learn to configure hibernate/JPA support in Spring Boot2 applications, along with creating entity classes and extending inbuilt JpaRepository interfaces.

Spring Boot Embedded Server Logs

Learn to enable and customize the internal and access logs generated for embedded servers in Spring boot e.g. tomcat, jetty & undertow.

How to Shutdown a Java ExecutorService

Learn ExecutorService shutdown(), shutdownNow() and awaitTermination​() APIs and how to use them correctly to shutdown executor under different conditions,

Java ExecutorService invokeAll()

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.

ExecutorService invokeAny()

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.

Executor RejectedExecutionHandler

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 …

Guide to ExecutorService in Java

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.

Compact Number Formatting in Java

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.

Java 11 Files.readString()

Learn to read a file to string in Java using Files.readString(path) method. This API has been introduced in Java 11.

Collectors teeing() Examples

Learn about Collectors.teeing() method (added in Java 12), method syntax and how to apply teeing() method in various usecases in Java.

Java 11 new features and enhancements

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 – New features and enhancements

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.

Java Program to Check Deficient number

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.

About Us

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.