Home » Java » Core Java (page 12)

Core Java

5 Refactoring Principles by Example

This post features five (mostly well-known) refactoring principles applied when refactoring real open-source code (Gradle Modules Plugin). Context When I worked on separate compilation of module-info.java for Gradle Modules Plugin (PR #73), I noticed potential for some refactoring. As a result, I filed issue #79 and later resolved it with PR #88 (not merged yet), where I refactored the code. ...

Read More »

A New Era for Determining Equivalence in Java?

Liam Miller-Cushon has published a document simply called “Equivalence” in which he proposes “to create a library solution to help produce readable, correct, and performant implementations of equals() and hashCode().” In this post, I summarize some reasons why I believe this proposal is worth reading for most Java developers even if the proposal never gets implemented and why the proposal’s ...

Read More »

Using Spliterator In Java

Introduction: Iterators in Java are used to traverse elements of a given source. Spliterator in Java is one among the four available Java Iterators – Iterator, Enumeration, ListIterator, and Spliterator. It is an interface available in java.util package. Spliterator was first introduced in Java 8 to support parallel programming. However, we can use it for both sequential and parallel processing ...

Read More »

How to Create QRCode Using QRGen in Java

In one of my previous articles, we saw how to create QRCode and its SVG equivalent using Zxing Java library. The Zxing library is no longer actively maintained and for this, there is a wrapper around Zxing library called QRGen, which provides much higher level APIs and a builder syntax for generating QR Codes. In this article, we will see ...

Read More »

OpenJDK on GitHub

Project Skara was created “to … investigate alternative SCM and code review options for the JDK source code, including options based upon Git rather than Mercurial, and including options hosted by third parties.” The OpenJDK skara-dev mailing list included a post from Robin Westberg last week that announced, “We have added some additional read-only mirrors of a few different OpenJDK ...

Read More »

How to create a QR Code SVG using Zxing and JFreeSVG in Java?

In this article, we will look at how to use the Zxing QR code generation library and JFreeSVG library to create a QR Code SVG image in Java. QR Code Generation The below code creates a java.awt.image.BufferedImage object representing QR Code using Zxing library: 1 public static BufferedImage getQRCode(String targetUrl, int width,     int height) {     try {         Hashtable<EncodeHintType, Object> hintMap ...

Read More »

How to Use Nutch From Java, Not From the Command Line

Apache Nutch is an open source framework written in Java. Its purpose is to help us crawl a set of websites (or the entire Internet), fetch the content, and prepare it for indexing by, say, Solr. A pretty useful framework if you ask me, however it is designed to be used onlymostly from the command line. You download the archive, ...

Read More »

Java Stream: Part 2, Is a Count Always a Count?

In my previous article on the subject, we learned that JDK 8’sstream()::count takes longer time to execute the more elements there are in theStream. For more recent JDKs, such as Java 11, that is no longer the case for simple stream pipelines. Learn how things have gotten improved within the JDK itself. Java 8 In my previous article, we could ...

Read More »

JDK 12 – JEP 325 Switch Expressions

JDK 12 went GA on March 19, 2019, keeping its word on shorter release cycles and frequent releases. The features part of the release can be found here. One of the interesting features for the developers is the “JEP 325 Switch Expressions” which is available as a preview feature. A preview feature as defined here is: A preview language or ...

Read More »