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:

Java – Create an Object without ‘new’ Keyword

We all know how to create objects of any class. The simplest method to create an object in Java is using new keyword. Let’s explore other methods to create objects without new keyword. 1. Using Class.newInstance() The Class.forName() loads the DemoClass in memory. To create an instance of this class, …

Dead code and Unreachable code in Java

Learn to identify dead code and unreachable code in Java, with example. It may be asked in your Java interview coding problems as a puzzle. Let’s sovle it.

Building HATEOAS Links with RESTEasy and JAX-RS

HATEOAS is a constraint on REST that says that a client of a REST application need only know a single fixed URL to access it. Any and all resources should be discoverable dynamically from that URL through hyperlinks included in the representations of returned resources.

Java Synchronous and Asynchronous Exceptions

In this Java tutorial, learn about asynchronous and synchronous exceptions in Java. Also, learn how they are different with checked and unchecked exceptions. 1. Asynchronous and synchronous exceptions Normally Java differentiates the exceptions into two categories on basis of “timing” when they are discovered. These categories are checked and unchecked …

Java Diamond Operator

Java diamond operator. Denoted with <> characters. It is also called elvis operator. It removes redundant type information from parameterized types in generics.

Java Deep Copy using In-memory Serialization

We all know that the easiest way of deep cloning (with some performance overhead) or deep copy is serialization. Java serialization involves serializing the object into bytes and from bytes to the object again. We suggest using in-memory deep cloning whenever it is the only need and we don’t need …

How to Print an Array in Java

Learn to print simple array and 2d array in Java. For nested arrays, the arrays inside array will also be traversed in this Java print array example.

Java Double Brace Initialization

Java double brace initialization example. Learn what is double brace initialization, it’s performance and what each brace means?

Method Hiding in Java

Declaring similar static methods in parent and child classes is called method hiding. For non-static methods, it is method overriding.

Hibernate / JPA One-to-Many Mappings

Hibernate one to many mapping is made between two entities where the first entity can have a relation with multiple instances of the second entity but the second can be associated with only one instance of the first entity. It is a 1 to N relationship. For example, in any …

Hibernate Hello World Example

Step by step hibernate hello world example with maven and eclipse. Learn to create, configure and store hibernate 5 entities in the database.

Java Memory Management – Garbage Collection Algorithms

We all are aware of the functional responsibilities of garbage collector [GC] in Java. But only few try to go real deep on how garbage collection works. You are not one of them and that’s why you are here. In this Java memory management tutorial, we will try to understand …

Java XPath Tutorial (with Examples)

Java XPath Example. XPath is a syntax used to describe parts of an XML document. In this tutorial, we will see some useful ways to apply xpath to extract information from an XML file.

Unit Testing Best Practices

It is overwhelmingly easy to write bad unit tests that add very little value to a project while astronomically inflating the cost of code changes. This post will go through the JUnit best practices we must consider while writing the test cases. In programming, “Unit testing is a method by …

Java main() Method

Have you ever tried to reason why Java’s main() method is public, static and void? Why its name is main? What happens inside JVM when you invoke main() method? What is the purpose of main method? Let’s find out. Since Java 21, we can create instance main() methods that do …

Abstract Factory Pattern

Abstract factory is a factory of factories; a factory that groups the individual but related/dependent factories together without specifying their concrete classes.

Immutable Classes in Java

Learn about immutable objects, records and collections in Java and create a Java class immutable step by step with examples.

Java String Interview Questions

All of us must have gone though interview questions related to String class in java. These String interview questions range from immutability to memory leak issues.

Factory Pattern

The factory pattern simply generates an instance for client without exposing its instantiation logic to the client.

Singleton Pattern (with Example)

To create a singleton, make the constructor private, disable cloning, disable extension and create a static variable to house the instance

Abstraction in Java

In simple words, java abstraction captures only those details about an object that is relevant to the current perspective. Learn more about abstraction in java.

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.