Home » Java » Core Java

Core Java

Optional orElse vs orElseGet

Java 8 introduced a fantastic concept of Optional, which we looked into in our blog Java 8 Optional. So just to give a short recap, Optional is used to represent Optional object or empty value instead null reference. This will help to avoid null pointer exception which occurs when we try to perform some operation on null reference object. For accessing ...

Read More »

Better NullPointerException Messages Automatic in JDK 15

I discussed long-awaited and highly appreciated improvements to NullPointerException (NPE) messages in the posts “Better Default NullPointerException Messages Coming to Java?” and “Better NPE Messages in JDK 14“. When this JEP 358-driven feature was added to JDK 14, a developer who wanted to benefit from these more insightful NPE messages needed to explicitly state that desire by passing the argument ...

Read More »

Reverse A String Using Recursion

1. Introduction In this article, You’re going to learn how to reverse a string using recursion approach. The first program is to reverse a string and the second program will read the input from the user. In the previous articles, I have shown already how to reverse a string without using any built-in function and also how to reverse the words in a ...

Read More »

Java Program To Insertion Sort

Java Program To Insertion Sort With Example. Shown the example simulation along with the time complexity. 1. Introduction Insertion sort is a simple sorting algorithm that builds the final sorted array (or list) one item at a time. It is much more efficient than Bubble Sort and less efficient on large lists than more advanced algorithms such as quicksort, heapsort, ...

Read More »

Local records or classes to improve the readability of stream operations

Java 14 came with the preview language feature of Records — a special lightweight class, comparable to similar constructs in other languages, such as record classes in C#, data classes in Kotlin and case classes in Scala. There’s A) already numerous blog posts explaining Java 14 records and B) numerous articles comparing usage of records with Project Lombok’s @Value (for ...

Read More »

Look for exceptions, errors in thread dumps

Thread dumps are vital artifacts to troubleshoot/debug production problems. In the past we have discussed several effective thread dump troubleshooting patterns like: traffic jam, treadmill, RSI, all roads lead to rome ………. In this article we would like to introduce one more thread dump troubleshooting pattern. 1 2 How to capture thread dumps? There are 8 different options to capture ...

Read More »

Tycoon: Ransomware Targeting Java’s JIMAGE on Multiple Platforms

The Blackberry Research and Intelligence Team and KPMG’s UK Cyber Response Services Team have reported “Threat Spotlight: Tycoon Ransomware Targets Education and Software Sectors.” This report outlines the “multi-platform Java ransomware targeting Windows and Linux that has been observed in-the-wild since at least December 2019” and which they’ve called “Tycoon.” The report provides a high level description of how the ...

Read More »

Java Text Blocks

Text Blocks are a JDK Enhancement Proposal (JEP 355) available as preview language feature in JDK 13 and 14. It is planned to become a permanent feature in JDK 15. A Text Block is a String literal that spans over multiple lines and avoids the need for most escape sequences. Motivation Embedding formats like XML, JSON or SQL in standard ...

Read More »

Octopus Scanner: Java Build Tools and Malware

Alvaro Munoz recently posted “The Octopus Scanner Malware: Attacking the open source supply chain” on the GitHub Security Lab site. I found this post to be interesting for a number of reasons, including its detailed coverage of how the Octopus Scanner malware works and how it was discovered, how the GitHub Security Incident Report Team (SIRT) went about addressing it, ...

Read More »