Home » Java » Core Java » Page 50

Core Java

EnumSet for enum collections

In the last blog post we discovered EnumMaps for mappings with enum keys. You might have observed that there is also a specialized Set that is optimized for enums: EnumSet. We again define a CoffeeType enum: public enum CoffeeType { ESPRESSO, POUR_OVER, FRENCH_PRESS, LATTE, FLAT_WHITE } Now we can create sets of this enum type, by using the EnumSet implementation: ...

Read More »

Mapping enum keys with EnumMaps

Here’s a type that has been around in the JDK for a while and that comes in handy when we want to define maps with enum types as keys: An EnumMap is a such as specialized Map. We’ll create a map for a given enum: public enum CoffeeType { ESPRESSO, POUR_OVER, FRENCH_PRESS } The EnumMap needs to be aware of ...

Read More »

Free Webinar: Swallowed Exceptions in Java Applications

Join our webinar on January 30th to discover the “hidden” exceptions in your Java Application. If a tree falls in the forest, but it isn’t written to the logs, does it make a sound? The answer, of course, is yes. Those are the kinds of errors that can have a severe impact on user experience without giving any visibility into ...

Read More »

The Educational Aspect of Static Analysis

Very often new programmers who join our projects ask us whether we have auto-formatting instruments to make Java code look exactly the way Qulice expects. (Qulice is the static analyzer we use.) I always reply that having such an automated code polisher would only be harmful and wouldn’t help the project and its members improve and grow. Here is why ...

Read More »

Using Google’s Protocol Buffers with Java

Effective Java, Third Edition was recently released and I have been interested in identifying the updates to this class Java development book whose last edition only covered through Java 6. There are obviously completely new items in this edition that are closely related to Java 7, Java 8, and Java 9 such as Items 42 through 48 in Chapter 7 ...

Read More »

What’s New in Effective Java’s Third Edition?

Ever since hearing about the pending publication of the Third Edition of Effective Java, I’ve wondered what would be new in it. I assumed that features introduced to Java since Java 6 would be covered and that is indeed the case. However, there are some other changes as well to this third edition of the Java developer classic. In this ...

Read More »

How to Add JARs to a Jetbrains MPS Project

Jetbrains MPS is a wonderful tool to create DSLs. We love it and use it regularly in our consultancy work. So we have written about Jetbrains MPS before. Being a projectional editor allows you to easily create DSLs that can be used through a graphical interface or things like mathematical formulas. Though all this power requires a bit of preparatory ...

Read More »

How to write less and better code, or Project Lombok

I have long intended to write about Project Lombok, so much so that I am probably doing it when every self-respecting Java developer has already heard about it. Nevertheless, it is worth mentioning, if only to remind myself that one should not hesitate to try performance-enhancing tools and see if they fit, and Lombok is certainly enhancing performance of a ...

Read More »