Java Programming Tutorials

Java programming tutorials with many code examples!

Java null check

Problem:

How to do null check in Java? The old way was to do validation manually, but since Java 7 there’s a better way. In the following example we show the difference.

Read More

Share with the World!

Java Objects equals hashcode

Problem:

How to implement equals and hashcode using java.util.Objects? In the following example we show how to use these great, null-insensitive helper methods.

Read More

Share with the World!

Java Formattable example

Problem:

How to print Java object using custom format? Since Java 5 there’s Formattable interface exactly for that purpose. Here’s an example of how to use it.

Read More

Share with the World!

Java find annotated classes

Problem:

How to find annotated classes in Java? JDK by itself doesn’t provide such mechanism, but there are libraries that can do that. One of them is Reflections, which is used in the following example.

Read More

Share with the World!

Spring find annotated classes

Problem:

How to find annotated classes using Spring and read metadata from them? Sometimes you may want to attach metadata to your classes using custom annotations. Here’s an example how you can leverage Spring‘s classpath scanning mechanism to do that.

Read More

Share with the World!

Java reverse List

Problem:

How to reverse Java List when List doesn’t have such method? As usually the solution is in Java Collections API.

Read More

Share with the World!