Check If a String Contains Multiple Keywords 1. Introduction In this quick tutorial, we’ll find out how to detect multiple words inside of a string. 2. Our Example Let’s suppose we have the string: String inputString = “hello there, Baeldung”; Our task is to find whether the inputString contains the “hello” and… Continue Reading string-contains-multiple-words

Depth First Search in Java 1. Overview In this tutorial, we’ll explore the Depth-first search in Java. Depth-first search (DFS) is a traversal algorithm used for both Tree and Graph data structures. The depth-first search goes deep in each branch before moving to explore another branch. In the next sections, we’ll… Continue Reading java-depth-first-search

Java 8 Stream findFirst() vs. findAny() 1. Introduction The Java 8 Stream API introduced two methods that are often being misunderstood: findAny() and findFirst(). In this quick tutorial, we will be looking at the difference between these two methods and when to use them. Further reading: Filtering a Stream of… Continue Reading java-stream-findfirst-vs-findany

Performance of contains() in a HashSet vs ArrayList 1. Introduction In this quick guide, we’re going to discuss the performance of the contains() method available in java.util.HashSet and java.util.ArrayList. They are both collections for storing and manipulating objects. HashSet is a collection for storing unique elements. To learn more about the HashSet,… Continue Reading java-hashset-arraylist-contains-performance

Interpolation Search in Java 1. Introduction In this tutorial, we’ll walk through interpolation search algorithms and discuss their pros and cons. Furthermore, we’ll implement it in Java and talk about the algorithm’s time complexity. 2. Motivation Interpolation search is an improvement over binary search tailored for uniformly distributed data. Binary… Continue Reading java-interpolation-search