
How to Install .NET SDKs on macOS and Switch Between Multiple Versions
Hey, Tea Lovers! Lets see how to install single or multiple .NET SDKs on macOS and switch between them. Option 1: Using Homebrew The latest one can be directly installed by following command. brew install --cask dotnet-sdk For a specific version just suffix it with @<version> Example, for .NET 8 it would be, brew install --cask dotnet-sdk@8 Simply paste in terminal and run. Note: Homebrew currently only has limited versions so older versions might not be available. In that case, use Option 2 or 3. ...

HTTP Long Polling, All You Need to Know About
TL’DR: Long Polling is When a client requests something from the server, and the data is not present at the moment, then the server doesn’t reply immediately instead, The server keeps the connection open. Once the requested data is available (or configured max waiting time is over) Respond and close the connection. Now, let’s go about the subject a little deeper. ✋ Before Long Polling, Know About Polling Let me start with the requirement. Let’s say I am building a Live Soccer Score Website. Users can see the latest score. On the client side, I will keep asking for updates on the scores at regular intervals, let’s say every 30 seconds. This is what polling is. ...

Easily Calculate Memory From Bytes to KB, MB, GB, TB
Here is the list with numbers of bytes for each size. With this, you can quickly identify which size metric to show instead of saying a number of bytes. Very helpful for your next System Design Interview. 1 Byte = 8 bit. For simplicity, I am using 1000 as the base instead of 1024 for KB and further calculations. You can mention this to the interviewer to make them aware. ...

How to Generate List from 1 to N in Java
There are multiple ways to generate the list from 1 to N or M to N in Java. We will look at 3 with various versions of Java. Using Simple For Loop Just iterate from 1 to N in for a loop and add it to the list. int n = 10; List<Integer> list = new ArrayList<>(n); // 1 to n (inclusive) for (int i = 1; i <= n; i++) { list.add(i); } Using IntStream - Java 8 Using IntStream’s range for end exclusive and rangeClosed for end inclusive. Here is how. ...

Java Sealed Classes: The Ultimate Guide to Secure Code
Hey Tea Lovers! We meet after a long time. Today’s post will be a short and cut-to-the-point post about the latest offering (relatively) by Java 17+. Yes, as you read in the title, it is about sealed classes in java. We will go over some of the basics and will give you some pointers that I think fully describes it. So let’s get to it. Introduction of Java’s Sealed Class The sealed class in Java is a new addition to the core library of java since Java 17. It is an introduction to the new keywords, sealed and non-sealed. The sealed class allows one to describe which class/interface can extend/implement the current class/interface. I will be using class throughout the post but it applies to both classes and interfaces in Java. ...

How to Easily use Factory Design Pattern in Java
Hey, Tea Lovers! Let me continue our design pattern series by adding this post. The Factory Design Pattern or Factory Method Design Pattern. It is one of the widely used and easy-to-understand Design patterns. It’s an effortless yet effective way of hiding object creation complexity. That’s why it is under the creation pattern category. So let’s jump right into it. Prerequisite to knowing Factory Design Pattern Before understanding what a factory design pattern is, you need to understand what superclass and subclass are. I am pretty sure you are aware of this detail, if not, the following section describes it in brief. if you already know it, you can skip to this part ...

Java Switch Statement is now more Powerful | Java 18
Hey Tea Lovers! Today let me talk about the Plain Old Java Switch Expression, but with a twist. This twist or update has been added to the core library of Java since Java 13. And If you are using Java version 13 or after, you can surely convert that old switch with the new one. I will talk about how it offers certain features in it without breaking existing changes. Of course, the other language users may comment “It was already there in our programming language years ago”. But let’s just smile, and continue coding in Java, shall we? One note, I will be using the " switch expression" and " switch statement" interchangeably in the post, so keep it in mind that I am trying to say the same thing. ...

What's new in Java 18? New Features of New Java 18
Hey Tea Lovers. On 22 March 2022, JDK 18 or Java 18 is released to the public (from Oracle). Java 18 does not contain any major updates that will change how we code, but it does have something very interesting. Few of the updates are in the incubator or preview mode. So for this article, I will be mostly focused on the core library addition. Don’t worry I will add a summary of other updates as well. ...

The Magic Behind HashMap and How it works in Java
Hey! tea lovers! In this post, we will be discussing how HashMap, the key-value-based data structure, works in Java. And it is one of the most asked interview questions as well. It is the core feature we as a developer use daily. Primarily used for easy and faster access to data based on the key. So let us see how it stores, retrieves and updates the data. I will put more articles under the Simply Explained tag. For now, let us get started with HashMap. So make your cup of tea to sip and code. ...

How to Analyze Time And Space Complexity of Algorithms
Hey, Tea Lovers! Starting your data structures and algorithm journey? Trying to solve more LeetCode or HackerRank or want to win Google CodeJam? Then this is the first thing you should know about, Time and Space Complexity of an Algorithm. We will see various ways we figure out the complexity, and how it is useful to determine the efficiency of an algorithm. With this, we can easily find out the Optimal Solution or algorithm among multiple. ...