Core Java

Java ClassLoaders

Introduction: In this tutorial, we’ll learn what is a classloader in Java. We’ll also look at various types of available Java Classloaders. A Classloader in Java is responsible for loading the required classes in memory dynamically at runtime. The classes aren’t loaded in memory all at once but rather when really needed by the application. […]

Be the First to comment. Read More
Core Java

Pairs In Java

Introduction: A Pair is an abstract data type which stores two items together which may or may not be related. They come handy when we want to track two objects together. We often feel the need to work with Pairs, specifically in competitive programming problems. In this tutorial, we’ll cover ways to define or use […]

Be the First to comment. Read More
Core Java

Check If Java Array Contains a Given Value

Introduction: In this quick tutorial, we’ll look at how to find if a Java array contains a given value. In other words, we’ll check if a given value is present in our Java array or not. Linear Search: One of the most straightforward approaches would be to linearly search our array to check if it […]

Be the First to comment. Read More
Core Java

Binary Search In Java

Introduction: In this quick tutorial, we’ll learn to perform a binary search in a sorted array. We’ll also write our own algorithmic implementation in Java. Later, we’ll discuss the binarySearch() method available in the Java library. Problem Definition: Let’s say we have a sorted array a[]: int[] a = {1, 2, 3, 4, 5, 6}; […]

Be the First to comment. Read More
Core Java

Polymorphism In Java

Introduction: Polymorphism in Java provides us an ability by which an object can take on different forms based on our usage context. Polymorphism is derived from two words – “poly” which means “many” and “morphs” which means “forms”. Java defines two major types of polymorphism: Compile-time / Static Polymorphism also referred to as “Method overloading” […]

Be the First to comment. Read More
Core Java

Find Middle Element In a Linked List

Introduction: In this quick tutorial, we’ll first start by looking at the brute-force solution to find the middle element in the linked list. Later, we’ll learn how to achieve it in a single iteration through the entire linked list i.e. in just a single pass. Problem Definition: Given a linked list L, our aim is […]

Be the First to comment. Read More
Core Java

Calculate Word Frequency Count In Java 8

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 […]

Be the First to comment. Read More
Spring

Spring : Injecting Prototype Beans Into Singleton Instance

Introduction: In the Spring framework when we inject a prototype bean into a singleton bean, it still behaves as a singleton. It’s known as prototype-bean injection problem. In this tutorial, we’ll learn ways in which we can inject a prototype instance into a singleton bean in Spring. It’s a scenario we’re most likely to encounter […]

One comment Read More
Core Java

Inheritance In Java

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 […]

Be the First to comment. Read More
Core Java

Comparable and Comparator In Java

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 = […]

Be the First to comment. Read More