Home » Java » Core Java (page 11)

Core Java

LinkedHashMap In Java

Introduction: LinkedHashMap is a Map implementation which maintains the insertion order of its elements. It extends the HashMap class: public class LinkedHashMap<K,V> extends HashMap<K,V> implements Map<K,V> Just like a HashMap, it allows storing one null key and many null values. Instantiating LinkedHashMap: We can use one of the following constructors to create a LinkedHashMap: LinkedHashMap() //default capacity 16 with load factor ...

Read More »

Java Text Blocks

In the 13 May 2019 post “RFR: Multi-line String Literal (Preview) JEP [EG Draft]” on the OpenJDK amber-spec-experts mailing list, Jim Laskey announced a draft feature JEP named “Text Blocks (Preview)” (JDK-8222530). Laskey’s post opens with (I’ve added the links), “After some significant tweaks, reopening the JEP for review” and he is referring to the draft JEP that was started ...

Read More »

Handling exceptions functional style

Java supports checked exceptions from the very start. With Java 8 the language element lambda and the RT library modifications supporting stream operations introduced functional programming style to the language. Functional style and exceptions are not really good friends. In this article, I will describe a simple library that handles exceptions somehow similar to how null is handled using Optional. ...

Read More »

Creating a Java::Geci generator

A few days back I wrote about Java::Geci architecture, code generation philosophy and the possible different ways to generate Java source code. In this article, I will talk about how simple it is to create a generator in Java::Geci. Hello, Wold generator HelloWorld1 The simplest ever generator is a Hello, World! generator. This will generate a method that prints Hello, ...

Read More »

Top 9 Free Java Process Monitoring Tools & How to Choose One

So your Java code runs. Perhaps it even runs on a production server. After you pat yourself on the shoulder on a job well done, we’ve got good news and annoying news. The annoying news is that now, the debugging starts. Debugging and application performance monitoring that is. This means looking beyond the code written and into the internal workings ...

Read More »

Java equals() and hashCode()

Introduction: Java Object class provides basic implementation of methods – hashCode() and equals(). These methods are extremely useful especially when working with the Collection framework. The hash table implementations rely on these methods for storing and retrieving data. In this tutorial, we’ll learn about the contract between hashCode() and equals(), their default implementations. We’ll also talk about when and how ...

Read More »

WeakHashMap In Java

A WeakHashMap in Java is a pretty popular data-structure among mid to senior-level Java developers. The WeakHashMap class is present in the java.util package. It’s a Map implementation which stores weak references to its keys. An entry in a WeakHashMap gets automatically removed when the associated key loses all of its active strong and soft references. In this post, we’ll first ...

Read More »

Functional Java by Example | Part 7 – Treat Failures as Data Too

This is part 7 of the series called “Functional Java by Example”. The example I’m evolving in each part of the series is some kind of “feed handler” which processes documents. We’ve already dealt with exceptional situations before, but we’re going to take care of them, more ehm,…functionally — as data. If you came for the first time, it’s best ...

Read More »