Java Programming Tutorials

Java programming tutorials with many code examples!

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!

Java Collection to Enumeration

Problem:

When working with legacy code, you need to convert Java Collection to Enumeration. This example shows how to do that using Java Collections API features!

Read More

Share with the World!

Java list replace/fill elements

Problem:

Sometimes we want on Java List replace/fill all/selected elements. It can be done manually, but much better way is to reuse Java Collections API. See how!

Read More

Share with the World!

Java find/count occurrences

Problem:

Sometimes you have to in Java find/count occurrences of objects inside a Java Collection. It can be done manually, but vast Java Collections API provides a better way.

Read More

Share with the World!