Try-with-resources Statement – Java 7

Many a times we forget to the close the file/jdbc resources that we open inside a try block after the operations are complete. This can cause memory leak issue. Starting from JDK 1.7, a new feature try-with-resource was introduced.This feature allows user

Read More

Sorting of ArrayList in Java using Comparators

In this article we will see the sorting of arraylist in java using comparators. This is mainly used for sorting arraylist that contain user defined objects. [crayon-5f741c8fb48a5135368048-i/] takes 2 parameters. 1st parameter is the list that needs to be sorted. 2nd parameter

Read More

Sorting of ArrayList in Java – primitives and literals

In this article we will explain the method used for sorting of arraylist for primitives/literals. Sorting of Arraylist for primitives and literals For sorting arrayList of any primitives or literals we use the [crayon-5f741c8fb4e18103884244-i/] [crayon-5f741c8fb4e21767704792/] ¬†Output  

Read More

How to Iterate through Hashmap

In this article we will focus on how to iterate through hashmap. There are many ways to iterate through HashMap’s in java. We will try some of them. Methods to iterate through hashmap Using for-each loop we can loop through the keySet

Read More