Home » Java » Core Java (page 10)

Core Java

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 »

When using JAXB

Not many examples show this, but how you use JAXB in your application can make a huge difference in the performance (and memory usage). The example In this blog post I’ll use an example Object called Membership that looks something like this: We will marshal and unmarshal this object to and from XML using JAXB. Create the context in a ...

Read More »

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 »