Blog
Page 769 of my articles, tutorials, and thoughts
Latest Articles
How do you assert that a certain exception is thrown in JUnit tests?
# How to Assert That a Certain Exception is Thrown in JUnit Tests ๐งช Are you tired of writing convoluted code to test if a specific exception is thrown in your JUnit tests? ๐คฏ Well, fret no more! In this blog post, we will show you a more elegant and idio
How can I create an executable/runnable JAR with dependencies using Maven?
# ๐ Creating an Executable JAR with Dependencies using Maven: A Complete Guide ๐ฆ So, you've built your awesome Java project, and now you want to package it into a single, self-contained JAR for easy distribution. But there's one problem โ your project h
What is a serialVersionUID and why should I use it?
# What is a serialVersionUID and why should I use it? ๐ค Have you ever encountered the warning message in Eclipse that says: > The serializable class [class name] does not declare a static final serialVersionUID field of type long. And you're probably w
How do I test a class that has private methods, fields or inner classes?
# Testing Classes with Private Methods, Fields, or Inner Classes So, you have this awesome class you've been working on, and it has some private methods, fields, or even nested classes. Now, you're faced with the challenge of testing it using JUnit. Howev
Initialization of an ArrayList in one line
# Initializing an ArrayList in One Line: The Easiest Way! ๐ Are you tired of writing multiple lines just to initialize an ArrayList? ๐ฉ Look no further! In this blog post, we will explore a super easy and concise way to initialize an ArrayList in just on
How do I convert a String to an int in Java?
# How to Convert a String to an int in Java: A Complete Guide So, you want to convert a `String` to an `int` in Java, huh? Well, don't worry, because I've got you covered! ๐ ## The Problem Let's say you have a `String` containing a numeric value, like
What is the difference between public, protected, package-private and private in Java?
## What's the Deal with Access Modifiers in Java? ๐ค Are you diving into the realm of Java programming and find yourself confused about when to use those access modifiers? Don't worry, my tech-savvy friend, I've got you covered! In this blog post, we'll d
When to use LinkedList over ArrayList in Java?
# When to use LinkedList over ArrayList in Java? ๐ As a Java developer, you might have come across the dilemma of choosing between `LinkedList` and `ArrayList` when working with lists. Both offer similar functionality, but they have different underlying
How can I create a memory leak in Java?
## Creating a Memory Leak in Java: A Beginner's Guide ๐จโ๐ป๐ So, you just had an interview and you were asked to create a memory leak in Java? Don't worry! It's not as complicated as it sounds. In this blog post, we'll break it down for you, addressing c
Iterate through a HashMap
# ๐ Mastering HashMap Iteration in Java ๐ Hey there, tech enthusiasts! Today, we're diving into the world of HashMap iteration in Java. If you've ever found yourself scratching your head, wondering how to efficiently loop through the items in a HashMap,