Java Programming Tutorials

Java programming tutorials with many code examples!

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 Reflection Generic Type

Problem:

How to get Java generic type parameter using reflection in runtime? Java doesn’t make it easy with type erasure, but it’s possible. See how.

Read More

Share with the World!

Bash array

Problem:

How to use Bash arrays? Bash is very flexible and allows to do funny things with arrays. Check out these cool Bash array examples.

Read More

Share with the World!

Java immutable List

Problem:

How to create an immutable List in Java? There are couple of ways to do that, one of them is to use Java Collections Framework as can be seen in the following example.

Read More

Share with the World!

Java synchronized List

Problem:

How to use Java List in a thread-safe way? It can be synchronized manually or you can use a wrapper method from Java Collections Framework. Learn how to use it correctly.

Read More

Share with the World!

Java List swap

Problem:

How to swap elements in Java List? Swap operation is very often used when implementing sorting. In the following example we show Java List swap operation from Java Collections Framework.

Read More

Share with the World!

Java sort List

Problem:

How in Java sort List? Java allows to sort list elements using their natural ordering or using custom Comparators. In the following example we present both approaches.

Read More

Share with the World!

Java singleton List

Problem:

How to create Java singleton List is the easiest way? Java Collections Framework has a couple of handy methods to create singleton List, singleton Set, and singleton Map. See the example.

Read More

Share with the World!

Java randomly shuffle

Problem:

How in Java randomly shuffle an array or List? This common problem can be solved with Java Collections Framework as in the following example.

Read More

Share with the World!
Pages:1...21222324252627...32