Introduction: In this quick tutorial, we’ll look at ways in which we can create a word frequency map in Java 8. Problem Definition: Let’s say we have been given a list of names: List<String> names = {"Sam", "James", "Selena", "James", "Joe", "Sam", "James"}; We wish to print the frequency map specifying the frequency count of […]
Introduction: Inheritance is one of the core principles of Object Oriented Programming. It enables us to establish IS-A relationship between classes/objects and reuse existing code. It is through the support of inheritance that we can extend a class from another. It’s kind of establishing a parent-child relationship among classes that relate to each other. Let’s […]
Introduction: In this tutorial, we’ll learn about Comparable and Comparator interfaces in Java. It’ll help us to compare our custom object types. Building Context: Let’s suppose we have our Student class: class Student { private int id; private String name; //constructor, getters, setters } And we have a List of Student objects: List<Student> students = […]
Overview: In this quick tutorial, we’ll learn ways in which we can invert or reverse an array. We’ll first look at the most basic Java implementations and later cover a few third-party options. Problem Definition: Consider we have an array of elements: Integer[] intArr = {12, 30, 1, 7, 4}; Our problem is to be […]
Introduction: The final keyword in Java is a non-access specifier. We can apply it to a variable, method or a class. In this tutorial, we’ll learn its usage in each of these contexts. final Variable: The variables declared as final are nothing but constants i.e. any attempt to reassign a value to those variables will […]
Introduction: Strings are used all over in any Java application. So, it’s important to understand how to compare two string objects. In this article, we’ll learn ways to compare String objects. 1.) Comparing References Using ‘==’ The == operator when used to compare strings is responsible for comparing only the references(not the content). So […]
Introduction: In this article, we’ll learn to find the sum and average of all elements in a given Java array. We’ll first cover the basic for loop-based approach and then extend our knowledge to achieve the same using Java Streams API. Finding Sum of Elements In Array: Let’s look at how we can find the […]
Introduction: In this quick tutorial, we’ll learn ways to find the maximum/minimum element in a Java array of primitives. We’ll start with the very basic algorithms and end up with a solution using Java 8 Streams API. Approach 1:: Linear Search It is a pretty straightforward approach to find max/min elements in a given […]
Introduction: The two terms truststore and keystore are often confused and seem daunting to even many senior developers at first. In this tutorial, we’ll cover the differences between a truststore and a keystore. We also suggest you read our article on How Https Works – SSL/TLS, which will help you understand the basics of Http […]
Introduction: Oracle Java 9 has a large set of new features including the various upgrades to the programming tools and libraries. In this tutorial, we’ll have a look at a few of those features. 1.) Java 9 REPL(JShell) Let’s cover the fun part first! In Java 9, Oracle introduced a tool called REPL(Read Evaluate Print […]