Home » Java » Core Java

Core Java

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 »

Is your JVM leaking file descriptors – like mine?

Foreword: The two issues described here, were discovered and fixed more than a year ago. This article only serves as historical proof, and a beginners’ guide on tackling file descriptor leaks in Java. In Ultra ESB we use an in-memory RAM disk file cache for fast and garbage-free payload handling. Some time back, we faced an issue on our shared ...

Read More »

The Structural Bug

A team member was having a bit of trouble with the following code: 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 void extractData(String targetUri) {     Path tempFile = createTempFilePath();     extractDataToPathAndUpload(tempFile, targetUri);     cleanUp(tempFile); }   void extractDataToPathAndUpload(Path tempFile, String targetUri) {    try (FileOutputStream stream = createOutput(tempFile)) {       // extract from db to file stream ...

Read More »

Date/Time Printing Can Be Elegant Too

I owe my pretty high StackOverflow reputation to this question in particular, which I asked a few years ago: How do you print an ISO 8601 date in Java? It managed to collect a lot of upvotes since then and 20+ answers, including my own one. Seriously, why didn’t Java, such a rich ecosystem, have a built-in out-of-the-box simple solution ...

Read More »