Home » Java » Core Java

Core Java

Ineffective Java

Perhaps I can be replaced by a robot for code review. There are some bits of feedback I find myself giving over and over again. Here are some of my least favourites: General Code Structure Drop The Else When if ends in return the else is superfluous and creates unnecessary indentation. 01 02 03 04 05 06 07 08 09 ...

Read More »

Java Record

The https://openjdk.java.net/jeps/359 outlines a new Java feature that may/will be implemented in some future versions of Java. The JEP suggests having a new type of “class”: record. The sample in the JEP reads as follows: 1 2 3 4 5 6 record Range(int lo, int hi) {   public Range {     if (lo > hi)  /* referring here to the implicit ...

Read More »

JAR File Handles: Clean Up After Your Mess!

In Ultra ESB we use a special hot-swap classloader that allows us to reload Java classes on demand. This allows us to literally hot-swap our deployment units – load, unload, reload with updated classes, and phase-out gracefully – without restarting the JVM. Windows: supporting the forbidden land In Ultra ESB Legacy the loader was working fine on Windows, but on ...

Read More »

Become a Master of Java Streams – Part 2: Intermediate Operations

Just like a magic wand, an Intermediate operation transforms a Stream into another Stream. These operations can be combined in endless ways to perform anything from simple to highly complex tasks in a readable and efficient manner. This article is the second out of five, complemented by a GitHub repository containing instructions and exercises to each unit. Part 1: Creating ...

Read More »

The Problem With Creating Generic Arrays

In this post, we feature a comprehensive article which explains the Problem with creating Generic Arrays. The Java programming language added generics in September of 2004 in the Java 5.0 “Tiger” release. The system of generics or type parameterization, extends Java’s existing type system while providing type safety. 1. Introduction Java has the Collections Framework, providing a library of generic ...

Read More »

OutOfMemoryError related JVM arguments

JVM has provided helpful arguments to deal with OutOfMemoryError. In this article, we would like to highlight those JVM arguments. It might come handy for you when you are troubleshooting OutOfMemoryError. Those JVM arguments are: -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath-XX:OnOutOfMemoryError-XX:+ExitOnOutOfMemoryError-XX:+CrashOnOutOfMemoryError Let’s discuss these JVM arguments in detail in this article. (1). XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath Heap dump is basically a snapshot of memory. It contains details ...

Read More »

How to fix an illegal start of expression in Java

Have you ever come across this mind-boggling bug and wonder how to solve it? Let’s go through the post and study how we address the Illegal start of expression Java error. This is a dynamic error, which means that the compiler finds something that doesn’t follow the rules or syntax of Java programming. Beginners mostly face this bug in Java. ...

Read More »

Become a Master of Java Streams – Part 1: Creating Streams

Declarative code (e.g. functional composition with Streams) provides superior code metrics in many cases. Code your way through this hands-on-lab article series and mature into a better Java programmer by becoming a Master of Java Streams. The whole idea with Streams is to represent a pipeline through which data will flow and the pipeline’s functions operate on the data. This ...

Read More »

JEP 355 Text Blocks in JDK 13

JDK 13 went GA on September 17th, 2019 and the prominent new features are listed here. One of the new features is “text blocks”. This allows writing multiline strings easily without the need for concatenation while splitting into different lines. Lets quickly look at the different ways of creating multiline strings: String aBlock = """ SELECT id, first_name, last_name, dob FROM ...

Read More »