Java Programming Tutorials

Java programming tutorials with many code examples!

Java rotate List

Problem:

How in Java rotate List elements or move an element to specified position? Java Collections Framework has nice solutions for this problem.

Read More

Share with the World!

Java reverse Comparator

Problem:

How to sort Java array/List in reverse order? It can be done with Reverse Comparator that can be created using Java Collections API. This example demonstrates its usage with Java Arrays and Lists.

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!

Java Collections newSetFromMap

Problem:

In Java some Map implementations have corresponding Sets, but not all of them. How to create a Set with the same ordering, concurrency, and performance characteristics?

Read More

Share with the World!

Java Collections nCopies

Problem:

How to create a Java List with copies of the same element? Java Collections.nCopies(n, T) does that, but has its quirks. Read on…

Read More

Share with the World!

Java zip file

Problem:

Java has great support for Zip format and writing code in Java to zip/unzip file is really simple. Java 8 makes it even simpler. The following example shows how to zip and unzip file.

Read More

Share with the World!

Clojure switch case

One of the first control flow statements in many programming languages is switch-case. In Clojure switch case can be achieved in different ways, which we will show in this post.

Read More

Share with the World!

Java Enumeration to List

Problem:

When using legacy libraries sometimes you need to convert Java Enumeration to List to use it with modern code it comfortable way. Again Java Collections API comes to the rescue!

Read More

Share with the World!

Java List sublist

Problem:

How to find a first/last occurrence of sublist in Java List? As expected Java Collections API has a method for this. See the example for details.

Read More

Share with the World!